473,386 Members | 1,715 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,386 software developers and data experts.

load data infile - not working, omits some records!

I'm using a mysql monitor under cygwin (on win xp) to do a 'load data
infile' to put some data into a mysql database (I'm using the xampp
bundle)..

My problem is that I have a four line CSV file beign inserted, but only
two records actually get inserted:

mysql> use master; delete from data; LOAD DATA INFILE
'D:/customJobs/database setup/dbaseFourLines.csv' REPLACE INTO TABLE
data FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' ESCAPED BY '\\';
Database changed
Query OK, 2 rows affected (0.00 sec)
Records: 2 Deleted: 0 Skipped: 0 Warnings: 12
Another csv file with 933 records gets imported ok...

Can someone confirm for me I am using the right syntax for import?
Could it be that my CSV file doesn't religiously quote every field?
(i.e. empty fields are just empty, do not contain "")

I've tried removing the OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\' from
the end and I get the same results.
The table structure is very 'normal' - the only only primary key is the
auto-increment index ID, the rest are normal fields (i.e. not primary,
unique, or index).

alex
Jul 20 '05 #1
2 7026
Alex Hunsley wrote:
I'm using a mysql monitor under cygwin (on win xp) to do a 'load data
infile' to put some data into a mysql database (I'm using the xampp
bundle)..

My problem is that I have a four line CSV file beign inserted, but only
two records actually get inserted:

mysql> use master; delete from data; LOAD DATA INFILE
'D:/customJobs/database setup/dbaseFourLines.csv' REPLACE INTO TABLE
data FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' ESCAPED BY '\\';
Database changed
Query OK, 2 rows affected (0.00 sec)
Records: 2 Deleted: 0 Skipped: 0 Warnings: 12
Another csv file with 933 records gets imported ok...

Can someone confirm for me I am using the right syntax for import?
Could it be that my CSV file doesn't religiously quote every field?
(i.e. empty fields are just empty, do not contain "")

I've tried removing the OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\' from
the end and I get the same results.
The table structure is very 'normal' - the only only primary key is the
auto-increment index ID, the rest are normal fields (i.e. not primary,
unique, or index).


update: I've made my CSV strictly quote every field, even if empty, and
I seem to be getting it to work now... is this a bug-bear with the CSV
import functionality of MySQL?

alex
Jul 20 '05 #2
Alex Hunsley wrote:
Alex Hunsley wrote:
I'm using a mysql monitor under cygwin (on win xp) to do a 'load data
infile' to put some data into a mysql database (I'm using the xampp
bundle)..

My problem is that I have a four line CSV file beign inserted, but
only two records actually get inserted:

mysql> use master; delete from data; LOAD DATA INFILE
'D:/customJobs/database setup/dbaseFourLines.csv' REPLACE INTO TABLE
data FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' ESCAPED BY
'\\';
Database changed
Query OK, 2 rows affected (0.00 sec)
Records: 2 Deleted: 0 Skipped: 0 Warnings: 12
Another csv file with 933 records gets imported ok...

Can someone confirm for me I am using the right syntax for import?
Could it be that my CSV file doesn't religiously quote every field?
(i.e. empty fields are just empty, do not contain "")

I've tried removing the OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\'
from the end and I get the same results.
The table structure is very 'normal' - the only only primary key is
the auto-increment index ID, the rest are normal fields (i.e. not
primary, unique, or index).

update: I've made my CSV strictly quote every field, even if empty, and
I seem to be getting it to work now... is this a bug-bear with the CSV
import functionality of MySQL?

alex

Ok, problem solved...
I needed to have this in my load data command:

LINES TERMINATED BY '\r\n'

... for windows line feeds.

lex
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

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: 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...
5
by: Justin | last post by:
Hi, im facing a problem here. First of all here is my program requirement. I got a .csv file with thousands of records inside, i need to import them into my mysql database. So i tried using load...
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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: 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
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.