473,387 Members | 1,578 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

LOAD DATA INFILE help

101 100+
I've got a comma delimited txt file that goes like this:

1,3,6,3,,5,3,1
2,3,4,3,3,5,3,1

Sometimes there are empty values that just show a double comma: ",,".

So, when I use this command....

Expand|Select|Wrap|Line Numbers
  1. load data infile 'C:/test.txt'
  2. into table MyTable
  3. fields terminated by ','
  4. lines terminated by '\n'
  5. (a, b, c, d, e, f, g, h);
... I get an error, since the datatypes are INT. MySQL interprets the "nothing" in-between the commas to be a string.

Can anybody help me?
Jan 24 '08 #1
1 1149
r035198x
13,262 8TB
I've got a comma delimited txt file that goes like this:

1,3,6,3,,5,3,1
2,3,4,3,3,5,3,1

Sometimes there are empty values that just show a double comma: ",,".

So, when I use this command....

Expand|Select|Wrap|Line Numbers
  1. load data infile 'C:/test.txt'
  2. into table MyTable
  3. fields terminated by ','
  4. lines terminated by '\n'
  5. (a, b, c, d, e, f, g, h);
... I get an error, since the datatypes are INT. MySQL interprets the "nothing" in-between the commas to be a string.

Can anybody help me?
What was the exact error message you got?






reference[/url]] An empty field value is interpreted differently than if the field value is missing:


  • For string types, the column is set to the empty string.
  • For numeric types, the column is set to 0.
Jan 24 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Bruce A. Julseth | last post by:
When I execute this SQL statement in my PHP code, I get an error "File '.\Address.txt' not found (Errcode: 2)" $File = addslashes(".\Address.txt"); $SQL = "Load Data InFile \"" . $File . "\"...
3
by: Otto | last post by:
Hello to all I have a problem how to write correctly a PHP string. I did the following import with the help of PHPMyAdmin: Nombre d'enregistrements insérés : 364 (traitement: 0.0553 sec.)...
3
by: hall | last post by:
I have a problem with my design of a templatized class. I'm trying to figure out how to load and save the data inside it, but can't. My class looks like this ------------------------------------...
0
by: Montagna, Dan | last post by:
------_=_NextPart_001_01C35B55.62B4A6E0 Content-Type: text/plain; charset="iso-8859-1" Hello, I'm a very new mysql/php user and am trying to use the load data infile command without luck. I'd...
0
by: Donald Tyler | last post by:
Then the only way you can do it that I can think of is to write a PHP script to do basically what PHPMyAdmin is trying to do but without the LOCAL in there. However to do that you would need to...
1
by: Jami Bradley | last post by:
HI all, For the past several months we have been using LOAD DATA LOCAL INFILE to bulk load tables within Perl modules. Recently, someone thought it would be a good idea to upgrade the Solaris...
1
by: Ray in HK | last post by:
What are the differences between LOAD DATA INFILE and LOAD DATA LOCAL INFILE ? I found some web hosting company do not allow using LOAD DATA INFILE but allow LOAD DATA LOCAL INFILE. The reason...
3
by: nsh | last post by:
mailing.database.mysql, comp.lang.php subject: does "LOAD DATA" EVER work?!? I've tried EVERYTHING! version info: my isp is running my web page on a linux box with php ver. 4.4.1 according to...
0
by: lanesbalik | last post by:
hi all, right now i'm trying to migrate from db2 running under linux to mysql v5.1. i manage to export out the db2 structure & data into a del (ascii) file. but when i try to load the data...
1
by: Megi | last post by:
welcome, I input data form file to mysql with command: load data local infile.. The efect is that the data are duplicated or trippled..etc with every re-loading the script, but I need to load...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.