If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Help with Load Data Infile

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-21-10, 17:19
sysenm sysenm is offline
Registered User
 
Join Date: Oct 2010
Posts: 12
Help with Load Data Infile

Hi all,

I am trying to load a data file into a table. The table structure is as follows:
____________________
Col1 | col2 | col3 |
-----------------------
Col1 is auto incremented, primary key

My query is
LOAD DATA INFILE 'c:\\s.txt' INTO TABLE my_table (col2,col3);

I get a 1261 error (row 1 does not contain data for all columns) . Any guideline what i am doing wrong here.

Thank you!
Reply With Quote
  #2 (permalink)  
Old 11-21-10, 17:33
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
could we have a look at the first few lines of data in the s.txt file, please

i think you may have forgotten to specify how the fields are separated

the default is a tab
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 11-21-10, 17:47
sysenm sysenm is offline
Registered User
 
Join Date: Oct 2010
Posts: 12
Thanks for quick reply, The s.txt is like following.

xxxContext601CBR 0.811
xxxContext602CBR 0.813
xxxContext603CBR 0.800
xxxContext604CBR 0.877
xxxContext605CBR 0.867

Its tab. I have also tried using different seperators and specifying that with "Fields terminated by" and "lines terminated by" but its not working.
Reply With Quote
  #4 (permalink)  
Old 11-21-10, 17:54
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
Originally Posted by sysenm View Post
Its tab.
hmm, well, you must've converted your tabs to spaces when pasting here, because i don't see no tabs in those records

also, "its not working" is not enough information to go on

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 11-21-10, 18:01
sysenm sysenm is offline
Registered User
 
Join Date: Oct 2010
Posts: 12
Quote:
Originally Posted by r937 View Post
hmm, well, you must've converted your tabs to spaces when pasting here, because i don't see no tabs in those records

also, "its not working" is not enough information to go on


I am using the defaults (tab for field separation and end-of-line for line separation. I am getting the same error "row 1 does not contain data for all columns" over and over,
Reply With Quote
  #6 (permalink)  
Old 11-21-10, 18:05
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
okay, here's an idea

grab the first dozen rows or so of your data, save as a text file, attach it to your post, and i'll test it here to see if i can get it working
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #7 (permalink)  
Old 11-21-10, 18:12
sysenm sysenm is offline
Registered User
 
Join Date: Oct 2010
Posts: 12
Thank you r937 !

The file is attached. BTW, I am working on a windows machine.
Attached Files
File Type: txt s.txt (408 Bytes, 39 views)
Reply With Quote
  #8 (permalink)  
Old 11-21-10, 18:32
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
well, it worked fine for me

i created a test table --
Code:
CREATE TABLE sysenm
( id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT
, foo VARCHAR(99)
, bar DECIMAL(5.4)
);
here's how i loaded it --
Code:
LOAD DATA INFILE 'C:/Documents and Settings/aldebaran.winxp/Desktop/s.txt'
INTO TABLE sysenm
FIELDS TERMINATED BY '\t'
( foo, bar )
and to prove i loaded it, i ran this query --
Code:
SELECT LEFT(foo,13) as qux
     , COUNT(*) AS rows
     , AVG(bar) AS avg_bar
     , MAX(bar) AS max_bar
  FROM sysenm
GROUP 
    BY qux
which produced these results --
Code:
qux          rows  avg_bar    max_bar
xxxContext601  4  0.83075000  0.8550
xxxContext602  4  0.85075000  0.8660
xxxContext603  3  0.84566667  0.8810
xxxContext604  3  0.86200000  0.8770
xxxContext605  3  0.83766667  0.8670
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #9 (permalink)  
Old 11-21-10, 18:49
sysenm sysenm is offline
Registered User
 
Join Date: Oct 2010
Posts: 12
Thank you very much.

I 'll check my table defination, thats the only thing left to check now. Thanks again
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On