Unix fFlat file to informix table
Posted in 2006
Topics: Stored Procedures & SPL
I'm looking for a utility to take a flat file of any size and break it up into fixed length records and insert into a database table. Example: cat big.txt | split_into_db informix_table Anyone seen anything like this?
Dr.Hunt wrote:
> I'm looking for a utility to take a flat file of any size and break it
> up into fixed length records and insert into a database table.
>
> Example: cat big.txt | split_into_db informix_table
>
> Anyone seen anything like this?
>
dbload
Dr.Hunt said: > I'm looking for a utility to take a flat file of any size and break it > up into fixed length records and insert into a database table. > > Example: cat big.txt | split_into_db informix_table > > Anyone seen anything like this? Yes. -- Bye now, Obnoxio "It's easier with pictures." -- Cosmo "But wait, it gets worse." -- Cosmo "Run, don't walk, for the nearest exit." -- Cosmo
Hi, the name of your file ("big.txt") implies that this is a text file, i.e. contains line feeds? And you want to load this into a database table, one line in the file becoming one value in a char column in the table, i.e. one table row per file line? In this case, lines are probably not of equal length in the text file. You'd therefore use some varchar column, put your favourite delimiter at the end of each line in the text file and then use "LOAD FROM ... INSERT INTO ...;" statement. If the file is not really a text file and does not contain line feeds (i.e. it is a binary file), then things are a bit more complicated. You'd probably have to write your own ESQL/C file (at least that's what I would do), to read the file in whatever format is required and then insert the stuff into the table accordingly. [ On some platforms you may find a split command that can break a binary file into smaller units, each with the length of fixed number of bytes. But I doubt this is what you want to do and that such a thing is suitable for your task. If the fixed length is rather small compared to the big file, you'd get an awful lot of files ...] If you have a text file (with line feeds), but you want to break these lines (of different lengths) into portions (records) of equal length to insert into a table, perhaps with fixed size char column ... Then one way is to first re-format the text file (to have all lines of equal length), then add your favourite delimiter and use "LOAD FROM ... INSERT INTO ...;". Though I doubt that the information will still be useful after this re-formatting ... Regards, Martin -- Martin Fuerderer IBM Informix Development Munich, Germany Information Management informix-list-bounces@iiug.org wrote on 07.03.2006 20:32:55: > I'm looking for a utility to take a flat file of any size and break it > up into fixed length records and insert into a database table. > > Example: cat big.txt | split_into_db informix_table > > Anyone seen anything like this? > > _______________________________________________ > Informix-list mailing list > Informix-list@iiug.org > http://www.iiug.org/mailman/listinfo/informix-list