If you are looking for fixed-width the following will be helpful:
"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 written and read using the ``display'' widths of the columns. For example, if a column is declared as INT(7), values for the column are written using 7-character fields. On input, values for the column are obtained by reading 7 characters. LINES TERMINATED BY is still used to separate lines. If a line doesn't contain all fields, the rest of the fields will be set to their default values. If you don't 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; see below. Note that fixed-size format will not work if you are using a multi-byte character set."
--http://www.mysql.com/doc
Essentially you will have to setup a table that has each column set to the right display width and then LOAD data with the FIELDS info set blank. That being said it would probably be easier to use a tool like Excel to import your fixed width file and save it as tab seperated.
Main Topics
Browse All Topics





by: BioIPosted on 2003-10-15 at 02:38:20ID: 9553340
Hi,
I am not really a mysql-expert, but it seems to me that you want to do a lot of patternmatches. Isn't it easier to write a small perl-script to parse your data and write them to the sql-databank using DBI? Or am I making things too complex?