Importing data from a csv file to mysql db -


i trying load data csv file still in excel. far statement have sql query:

load data local infile 'c:\\documents , settings\\j03299\\desktop\\tmeter.csv' table edata columns terminated ',' enclosed "" lines terminated '\n' (year,month,day,mjd,xpiles,xstacks,utilites); 

the file called tmeter , has 7 columns. has 366 rows. able read first row , first 4 columns(till mjd) else null after that. secondly in second row puts columns file (tmeter.csv) in row 124 first column of second row in edata table. confused to

  1. why doesn't read data column piles,stacks ,utilites? (mind column names in csv file weird , not same edata table e.g in database table piles while in actual csv file x(piles), stacks in table y(stacks) in csv file. mysql doesn't not allow me create etable names format had improvise. why not reading , mapping csv file table in mysql?
  2. why statement putting first row in csv file in first row in mysql table skipping down row 124 , inserting columns csv file first column of mysql database table?

sorry english not good. assistance appreciated.

when run command, should give message records: 1 deleted: 0 skipped: 0 warnings: 0. if there warnings, type show warnings see were.

this sounds behavior when line ending wrong. try opening document in code editor , checking make sure lines end \n. if that's inconvenient, try dropping table , reimporting lines terminated '\r' or lines terminated '\r\n' , see if fixes it.

regarding field names: command ignores field names in text file. match first column first field indicated in parentheses (in case, year) second column second field in parentheses (month), , on. if have field names @ top of file, should skip on them adding ignore 1 lines before parentheses list of fields.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -