ianhman Posted January 8, 2007 Share Posted January 8, 2007 Hi,I am a complete newbie to MySQL!I am trying to import a CSV file using phpMyAdmin.I have uploaded the CSV file via FTP to the root directory on my external server (GoDaddy). According to GoDaddy they allow importing of files into MySQL so there must be something wrong with my query.In phpMyAdmin I ran the following query:[code]load data local infile 'resdatatest2.csv' into table tblNewsletterSubsfields terminated by ','lines terminated by '\n'(ID, EcastID, Email)[/code]One the query has run phpMyAdmin then says the file has imported but with "Inserted rows: -1"so no actual data is being imported. It should have imported 284 rows, not -1 !The tblNewsletterSubs table structure is as follows:ID - int(7)EcastID - int(3)Email - varchar(75)I have attached a file sample of the CSV file I am using, I have stripped it down to 3 rows for test reasons. I can't see what is going wrong?Please help ???[attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
fenway Posted January 8, 2007 Share Posted January 8, 2007 Not sure... the statement itself might be producing an error that you're not seeing... are you sure your version supports specifying the column list? Quote Link to comment Share on other sites More sharing options...
ianhman Posted January 9, 2007 Author Share Posted January 9, 2007 I ended up having to convert the CSV file to an SQL file and insert the data that way by via the Import option on phpMyAdmin. Not ideal as this option only handles file up to 2MB in filesize on the host (GoDaddy) server.Earlier I mentioned to my host (GoDaddy) that I was trying to import a CSV file and showed them the query I was using. GoDaddy said they do support CSV import and that there was something wrong with my query??If anyone can provide further help it would be much appericated. Quote Link to comment Share on other sites More sharing options...
fenway Posted January 10, 2007 Share Posted January 10, 2007 Which version? Quote Link to comment Share on other sites More sharing options...
ianhman Posted January 11, 2007 Author Share Posted January 11, 2007 Hi fenway, the version of phpMyAdmin is 2.7.0-pl2 Quote Link to comment Share on other sites More sharing options...
fenway Posted January 11, 2007 Share Posted January 11, 2007 Sorry I wasn't clear... of the database. Quote Link to comment Share on other sites More sharing options...
ianhman Posted January 12, 2007 Author Share Posted January 12, 2007 Any ideas or suggestions ? Quote Link to comment Share on other sites More sharing options...
ianhman Posted January 12, 2007 Author Share Posted January 12, 2007 Version of MySQL is 4.0.24 Quote Link to comment Share on other sites More sharing options...
fenway Posted January 12, 2007 Share Posted January 12, 2007 I'd have to check the refman, but I think they added the ability to specify a column list only in later versions; you should probably just dump the whole thing into a temporary table, and then deal with just the fields of interest. Quote Link to comment Share on other sites More sharing options...
ianhman Posted January 13, 2007 Author Share Posted January 13, 2007 Thanks fenway, but how do I dump the file into a temporary table? Quote Link to comment Share on other sites More sharing options...
fenway Posted January 13, 2007 Share Posted January 13, 2007 Much as you have done, but without the column list. Quote Link to comment Share on other sites More sharing options...
Barand Posted January 14, 2007 Share Posted January 14, 2007 I recently upgraded from v3.?? and that had column list.As the file is on the server, remove the "local" keyword and specify the full path for the INFILE filename. Quote Link to comment Share on other sites More sharing options...
ianhman Posted February 2, 2007 Author Share Posted February 2, 2007 I still haven't had any joy with this guys. I tried taking out the word "local" and removed the column list but get the same problem....it imports -1 rows. I have my csv file uploaded to the root of my sever.Please help ??? Quote Link to comment Share on other sites More sharing options...
fenway Posted February 2, 2007 Share Posted February 2, 2007 Could you post some samples from the file? I can probably try it on my end sometime this weekend, though I don't have access to a 4.0 box, only 4.1. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.