dc_jt Posted June 12, 2007 Share Posted June 12, 2007 Hi Is this easily done? Ive never done it before and I need to do it. Any good tutorials anyone can recommend? Thanks Quote Link to comment Share on other sites More sharing options...
coderage Posted June 12, 2007 Share Posted June 12, 2007 If you are using mysql database, this query will do the trick LOAD DATA INFILE "C:\\YOURFILE.CSV" INTO TABLE YOURTABLE FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'; NOTE: Here you are using ' , ' as delimiter for fields, this means if some field in your tuple/ row of csv file has data such as text which in turn has comma in it, it will be broken down into two fields. So "condition" your csv file before you use this query. for simple example, try to import a file with these two lines in a test table with three fileds 1234,abcd,blue : will go ok 1234,ab,cd,blue : will no be imported as it will break ab,cd (which is one field in example) into two fields goodluck Quote Link to comment Share on other sites More sharing options...
cavey5 Posted July 29, 2007 Share Posted July 29, 2007 Can I put the csv file on my server and load it that way instead of from my C drive? Also, do the field names in the csv file have to match the sql table, or does it just need to be the same number of fields per row? 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.