Bluehost.com Web Hosting $6.95

load data local infile

This is a discussion on load data local infile within the MySQL Database forums, part of the Database Forums category; I use the subject command quite often to load .cvs files into tables and am very pleased with the speed. ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-08-2007
Lee Peedin
 
Posts: n/a
Default load data local infile

I use the subject command quite often to load .cvs files into tables
and am very pleased with the speed.

The "terminated by ','" is, of course what is used. After some
additional study, it appears that practically any character can be
used here if that character was what was used when the "text" file was
created.

My question is, is there a way to do this on fixed length files?


A little background. I have hundreds of old BTrieve files that I need
to move to MySQL. Current process is to read each row in the BTrieve
file and construct a "properly formated .cvs" file. Then use "load
data local infile" to load the table.

BTrieve comes with a utitility called "butil" that has an option to
"-save" the data in an unformated text file, but this file is a fixed
length.

Butil is considerably faster than reading each line and formatting it;
however, unless "load data" or some other MySql command can be used to
load the fixed length data, then I'm sure any time gained will be lost
by having to read and format each line of the butil generated file.

Any ideas?

Lee
Reply With Quote
  #2 (permalink)  
Old 02-08-2007
Captain Paralytic
 
Posts: n/a
Default Re: load data local infile

On 8 Feb, 12:31, Lee Peedin <lpeedinDONOTSP...@nc.rr.com> wrote:
> I use the subject command quite often to load .cvs files into tables
> and am very pleased with the speed.
>
> The "terminated by ','" is, of course what is used. After some
> additional study, it appears that practically any character can be
> used here if that character was what was used when the "text" file was
> created.
>
> My question is, is there a way to do this on fixed length files?
>
> A little background. I have hundreds of old BTrieve files that I need
> to move to MySQL. Current process is to read each row in the BTrieve
> file and construct a "properly formated .cvs" file. Then use "load
> data local infile" to load the table.
>
> BTrieve comes with a utitility called "butil" that has an option to
> "-save" the data in an unformated text file, but this file is a fixed
> length.
>
> Butil is considerably faster than reading each line and formatting it;
> however, unless "load data" or some other MySql command can be used to
> load the fixed length data, then I'm sure any time gained will be lost
> by having to read and format each line of the butil generated file.
>
> Any ideas?
>
> Lee


>From the MySQL manual (http://dev.mysql.com/doc/refman/5.0/en/load-

data.html):

If the FIELDS TERMINATED BY and FIELDS ENCLOSED BY values are both
empty (''), a fixed-row (non-delimited) format is used. With fixed-row
format, no delimiters are used between fields (but you can still have
a line terminator). Instead, column values are read and written using
a field width wide enough to hold all values in the field. For
TINYINT, SMALLINT, MEDIUMINT, INT, and BIGINT, the field widths are 4,
6, 8, 11, and 20, respectively, no matter what the declared display
width is.

LINES TERMINATED BY is still used to separate lines. If a line does
not contain all fields, the rest of the columns are set to their
default values. If you do not have a line terminator, you should set
this to ''. In this case, the text file must contain all fields for
each row.

Fixed-row format also affects handling of NULL values, as described
later. Note that fixed-size format does not work if you are using a
multi-byte character set.

Note: Before MySQL 5.0.6, fixed-row format used the display width of
the column. For example, INT(4) was read or written using a field with
a width of 4. However, if the column contained wider values, they were
dumped to their full width, leading to the possibility of a "ragged"
field holding values of different widths. Using a field wide enough to
hold all values in the field prevents this problem. However, data
files written before this change was made might not be reloaded
correctly with LOAD DATA INFILE for MySQL 5.0.6 and up. This change
also affects data files read by mysqlimport and written by mysqldump --
tab, which use LOAD DATA INFILE and SELECT ... INTO OUTFILE

Reply With Quote
  #3 (permalink)  
Old 02-08-2007
Lee Peedin
 
Posts: n/a
Default Re: load data local infile

On 8 Feb 2007 04:49:48 -0800, "Captain Paralytic"
<paul_lautman@yahoo.com> wrote:

>
>>From the MySQL manual (http://dev.mysql.com/doc/refman/5.0/en/load-

>data.html):
>
>If the FIELDS TERMINATED BY and FIELDS ENCLOSED BY values are both
>empty (''), a fixed-row (non-delimited) format is used. With fixed-row
>format, no delimiters are used between fields (but you can still have
>a line terminator). Instead, column values are read and written using
>a field width wide enough to hold all values in the field. For
>TINYINT, SMALLINT, MEDIUMINT, INT, and BIGINT, the field widths are 4,
>6, 8, 11, and 20, respectively, no matter what the declared display
>width is.
>
>LINES TERMINATED BY is still used to separate lines. If a line does
>not contain all fields, the rest of the columns are set to their
>default values. If you do not have a line terminator, you should set
>this to ''. In this case, the text file must contain all fields for
>each row.
>
>Fixed-row format also affects handling of NULL values, as described
>later. Note that fixed-size format does not work if you are using a
>multi-byte character set.
>
>Note: Before MySQL 5.0.6, fixed-row format used the display width of
>the column. For example, INT(4) was read or written using a field with
>a width of 4. However, if the column contained wider values, they were
>dumped to their full width, leading to the possibility of a "ragged"
>field holding values of different widths. Using a field wide enough to
>hold all values in the field prevents this problem. However, data
>files written before this change was made might not be reloaded
>correctly with LOAD DATA INFILE for MySQL 5.0.6 and up. This change
>also affects data files read by mysqlimport and written by mysqldump --
>tab, which use LOAD DATA INFILE and SELECT ... INTO OUTFILE


Thank you for the detailed explaination - all is well now and have cut
my BTrieve to MySQL transfer time by 75%!

Thanks
Lee
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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 04:43 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0