|
Hi,
I am transforming a CSV file to XML. The CSV file has 4921 records, and my xml output file only takes the first 2074 records. Here is the code I used from the XML and Perl book by Riehl and Stern to do this. I used an array to pass the column names since I do not get a header. Thanks,
John
--------
my $file = $_[0];
open (INFILE, $file) || die "Cannot open file: $file\n";
chomp $file;
my @column_names = qw( ACCOUNT ADDRESS_ID STREET_ADDRESS_LINE HOUSE
FST_DIR STREET STREET_SUFFIX SND_DIR UNIT
CITY_NAME STATE ZIP DLIVERY_INST ADDR_SUBACCT_ROUTE_ROWID
ROUTE DISTRICT ADI SUB_DISTRICT CARRIER_MOTOR PROD_CODE
PUBLICATION TRUCK SUB_STATUS COPIES RUNDATE
);
my $array_ref = \@column_names;
my $csv = XML::SAXDriver::CSV->new();
my $writer = XML::Handler::YAWriter->new(
Output => IO::File->new(">$PUT_TEXTFILEDIR"."RouteSmart".$fileDate.".xml"),
Pretty => {PrettyWhiteIndent => 1,
PrettyWhiteNewLine => 1});
$csv->parse(Source => {SystemId => $file},
Handler => $writer,
Declaration => {Version => '1.0'},
Col_Headings => $array_ref,
Dynamic_Col_Headings => 0);
|