Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to transfer data to mysql from .txt file

Status
Not open for further replies.
Apr 28, 2006
69
NL
Hi all i got a txt file that has a list of urls i want to transfer this to a table in mysql but i do not know how. I have phpmyadmin and mysql installed . Could an expert show me an easy and fast way to store these urls in a database.Thanks
 
You could, read the file, and put the contents into an array, and then ut it into he DB.

What format does the table have? fields, types etc...
How re the URL's separated in the txt file? by a comma, a space etc...

If this is a one time thing, then maybe the import feature in phpmyadmin is the way to go. if it is something that is going to happen frequently, then maybe a webpage with the approprite code is the way to go.

Tell us what exactly it is you want and we can help further.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Many thanks for u reply. This is my first tiime dealing data in text file. The text files contains urls one in ech line . Just like the example here:

.......................
.......................
I want to store it in table that has a few fields but at this momenent i want to fill its first field which is called url. I be happy if u assist me transfer them to mysql db.Thanks
 
You still have not answered wether it is a one time thing or will have to be done regularly and/or often.

Here arwe the instructions for phpMyadmin:
Importing the data

After logging in, navigate to the phpMyAdmin import screen by doing this:

* Look in the left-hand column and click on the name of the table into which you want to import the data.

* Click the Import tab that appears at the top of the page.

* Change the "Format of imported file" to CSV. (Do not choose "CSV using LOAD DATA"; it will not work.)

You'll then see a screen that allows you to choose the import options:

* Next to "Location of the text file", choose the file from your hard disk that you want to import.

* Change the Fields terminated by option to be a carriage return(\n\r) instead of the default semicolon.

* Leave the other options unchanged unless you know what you're doing.

* Press Go.

You should see something like Inserted rows: 1209 (Query took 0.00 sec) at the top of the screen. Click the Browse tab to review the imported data.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Many thanks for u reply. I think i am using diffrent version of phpmyadmin . I see on the screen the following . Should i just change the follwoings for type of data that i have in my txt file which is has no ; or any thing jut line by line? :

Fields terminated by
Column names

Furthermore, will i will probably doing this many time every 3 months or so . Is there any better way to do it and more automatic?Thanks
text2sql.jpg
 
To specify the line breaks, put
"[red]\n\r[/red]" in Fields Terminated By: and your column name I believe in Column Names. That Should do it.


----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top