Re: Loading Fixed Length ASCII / EBCDIC
Posted in 1997
John Cokos wrote > >Importing ASCII Files > I am able to convert and load from Delimited Ascii, and DBF files via 4gl > and Perl... > but I am having a lot of difficulty with Fixed Length and EBCDIC Files. > Has anyone solved this? Yes - > How? ------------cut here ---------------------------------------------------------- #! /usr/local/bin/isqlperl # open for input unless (open(DD,"dd if=ebcdic.file conv=ascii 2>/dev/null|")) { printf (STDERR "Can not open dd for input\\n"); exit(1); } ++$isql_autoclose; &isql_execute("database test") || die $isql_code; &isql_execute("begin work") || die $isql_code; while (<DD>) { chop; $key = substr($_,0,9); $field = substr($_,9,20); $value = substr($_,29,10); &isql_execute(sprintf( "insert into test values(\\"%s\\",\\"%s\\",\\"%s\\")\\n", $key,$field,$value)) || die $isql_code; } &isql_execute("commit work") || die $isql_code; --------------------cut here--------------------------------------------------- We use isqlperl to insert directly to the database; I you don't have that great tool :) you could easily write records for an unload file. > Is there some common utility for this that I am not seeing? Dunno. Salute, -- Chris Drauch <cdr@xteam.co.at> ... just speaking for myself ...