Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

LOAD DATA..........

 
   Database Help (Home) -> mySQL RSS
Next:  SAN Traning In Hyderabad @ Rrootshell.  
Author Message
Luuk

External


Since: May 18, 2008
Posts: 18



(Msg. 1) Posted: Thu Dec 29, 2011 6:25 am
Post subject: LOAD DATA..........
Archived from groups: comp>databases>mysql (more info?)

I have a textfile (tmp.csv) with the following contents:
"01-01-12";"text1";"text2"
"08-01-12";"text1, more text, more text";"text2"

i wanted to import this into a temporary table, so i did:
CREATE TABLE tmp (i1 varchar(100), i2 varchar(100), i3 varchar(100));

and to import this file:
LOAD DATA INFILE 'tmp.csv' INTO TABLE tmp FIELDS TERMINATED BY ';'
OPTIONALLY ENCLOSED BY '"';

it gives warnings like:
Row 1 was truncated; it contained more data than there were input columns

When i do a select * from tmp, i get:
"01-01-12 | text1 | text2"
"08-01-12 | text1, more text, more text | text2"

What should i do to import such simple text file ?


--
Luuk

 >> Stay informed about: LOAD DATA.......... 
Back to top
Login to vote
Luuk

External


Since: May 18, 2008
Posts: 18



(Msg. 2) Posted: Thu Dec 29, 2011 6:25 am
Post subject: Re: LOAD DATA.......... [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 29-12-2011 11:42, Luuk wrote:
> I have a textfile (tmp.csv) with the following contents:
> "01-01-12";"text1";"text2"
> "08-01-12";"text1, more text, more text";"text2"
>
> i wanted to import this into a temporary table, so i did:
> CREATE TABLE tmp (i1 varchar(100), i2 varchar(100), i3 varchar(100));
>
> and to import this file:
> LOAD DATA INFILE 'tmp.csv' INTO TABLE tmp FIELDS TERMINATED BY ';'
> OPTIONALLY ENCLOSED BY '"';
>
> it gives warnings like:
> Row 1 was truncated; it contained more data than there were input columns
>
> When i do a select * from tmp, i get:
> "01-01-12 | text1 | text2"
> "08-01-12 | text1, more text, more text | text2"
>
> What should i do to import such simple text file ?
>
>

adding a ';' at the end of the line seemes to solve the problem Wink

--
Luuk

 >> Stay informed about: LOAD DATA.......... 
Back to top
Login to vote
The Natural Philosopher

External


Since: Oct 01, 2009
Posts: 27



(Msg. 3) Posted: Thu Dec 29, 2011 7:26 am
Post subject: Re: LOAD DATA.......... [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Luuk wrote:
> On 29-12-2011 11:42, Luuk wrote:
>> I have a textfile (tmp.csv) with the following contents:
>> "01-01-12";"text1";"text2"
>> "08-01-12";"text1, more text, more text";"text2"
>>
>> i wanted to import this into a temporary table, so i did:
>> CREATE TABLE tmp (i1 varchar(100), i2 varchar(100), i3 varchar(100));
>>
>> and to import this file:
>> LOAD DATA INFILE 'tmp.csv' INTO TABLE tmp FIELDS TERMINATED BY ';'
>> OPTIONALLY ENCLOSED BY '"';
>>
>> it gives warnings like:
>> Row 1 was truncated; it contained more data than there were input columns
>>
>> When i do a select * from tmp, i get:
>> "01-01-12 | text1 | text2"
>> "08-01-12 | text1, more text, more text | text2"
>>
>> What should i do to import such simple text file ?
>>
>>
>
> adding a ';' at the end of the line seemes to solve the problem Wink
>
I was gonna suggest that..

but I didnt know what load data makes of newlines..
 >> Stay informed about: LOAD DATA.......... 
Back to top
Login to vote
onedbguru

External


Since: Jan 03, 2011
Posts: 11



(Msg. 4) Posted: Thu Dec 29, 2011 1:33 pm
Post subject: Re: LOAD DATA.......... [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Dec 29, 7:03 am, The Natural Philosopher
wrote:
> Luuk wrote:
> > On 29-12-2011 11:42, Luuk wrote:
> >> I have a textfile (tmp.csv) with the following contents:
> >> "01-01-12";"text1";"text2"
> >> "08-01-12";"text1, more text, more text";"text2"
>
> >> i wanted to import this into a temporary table, so i did:
> >> CREATE TABLE tmp (i1 varchar(100), i2 varchar(100), i3 varchar(100));
>
> >> and to import this file:
> >> LOAD DATA INFILE 'tmp.csv' INTO TABLE tmp FIELDS TERMINATED BY ';'
> >> OPTIONALLY ENCLOSED BY '"';
>
> >> it gives warnings like:
> >>  Row 1 was truncated; it contained more data than there were input columns
>
> >> When i do a select * from tmp, i get:
> >> "01-01-12 | text1 | text2"
> >> "08-01-12 | text1, more text, more text | text2"
>
> >> What should i do to import such  simple text file ?
>
> > adding a ';' at the end of the line seemes to solve the problem Wink
>
> I was gonna suggest that..
>
> but I didnt know what load data makes of newlines..

Try adding
LINES TERMINATED BY clause

http://dev.mysql.com/doc/refman/5.1/en/load-data.html
 >> Stay informed about: LOAD DATA.......... 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Want data from t1 based on data in t2 and t3. - I have a database with three tables in it. (t1) One of them holds a list of Decks. (t2) The second holds a list of the cards contained in every deck. (t3) The third contains all of the ratings any deck has received. What I'm trying to do is: SELECT *..

Best way to issue hundreds of inserts/updates??? - Using mysql 4.0.23- What is the best way to execute several (hundreds of) inserts and updates? Rather than issuing tons of individual inserts and updates, can I send the strings to a text file and then have mysql do them all?? IE : query.txt insert..

MySQL freezes, brings XP machine to a grinding halt - I've been using MySQL for a while for fairly light database development on my XP machine. Currently, I am just starting a new project and have experienced some big problems with MySQL today both on my office machine and at home where running a particular...

login as user 'root' but do not have root privlages and my.. - Hi gang: I'm experiencing a problem with MySQL -- I updated MySQL from version 4.1.0 to 4.1.10 and now when I login as root it doesn't show all the databases I should have access to, nor it doesn't recognize me being logged in as root (via..

FLUSH TABLES hangs if table is locked - Using FLUSH TABLES via the C query API mysql_query() hangs if the table is locked already. That is to say, nothing prevents me from running a LOCK TABLES twice; it won't tell me "it's already locked, don't try to run a FLUSH". Anyone know ...
   Database Help (Home) -> mySQL All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]