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!

i have a .csv file...can and should i upload to mysql datatbase...

Status
Not open for further replies.

spewn

Programmer
May 7, 2001
1,034
can i upload a .csv file to work with mysql?

- g
 
Yes, that's what i meant...

i have this:
Code:
$dbh=DBI->connect("DBI:mysql:db1_db2:localhost","exm_dbbb","pass");
$sth=$dbh->prepare("LOAD DATA INFILE 'namesfl.txt' INTO TABLE namesfld");
$sth->execute;

seems easy enough...the db is created already, with one field named "namesfld"...but when i run this, it doesn't populate the field in mysql.

in the txt file, the names are listed, one per line.

when i run the script, the names should be entered into db line by line, right?

- g
 
If you don't specify the delimiters MySQL will assume that your fields are separated with TABs. You will need to modify your LOAD DATA INFILE statement to specify that you are using commas.

Check out the MySQL documentation at


There's not much point in me copying it into this reply!

Andrew
Hampshire, UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top