[snip]
I need to break it up into fields....
[/snip]
Just to make sure that I understand...the data currently looks something
like;

100101TestFileData1Data2Data3

and you need the columns to be like;

100101 TestFile Data1 Data2 Data3

If you are on *nix you need to write a script to break up the data with a
known file delimeter such as a comma or tab, so the data looks like;

100101","TestFile","Data1","Data2","Data3

or

100101"/t"TestFile"/t"Data1"/t"Data2"/t"Data3

Then you can flag the mysqlimport command with --fields-terminated-by="/t"
or ","

I have written numerous awk scripts for this kind of problem, we use them
every day. Like this

-----
#!/bin/sh

awk ' {
        blank = ""
        RecordID = substr($0, 1, 6)
        RecordIDSuffix = substr($0, 7, 2)
        SuffixRecordInd = substr($0, 9, 1)

print blank","RecordID","RecordIDSuffix","SuffixRecordInd > "tblNAME.tmp"
        }
}'

/usr/local/bin/mysqlimport --host=host --user=user --password=user -f --fiel
ds-terminated-by="," databasename tblNAME.tmp
rm tblNAME.tmp
-----
blank is a place holder for the autoincrement field
each other variable is a substring from the overall fixed width record
print that info, with comma as delimeter to a tmp file with the same name as
the table
import that data
remove the tmp file

Jay Blanchard



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to