CSV files

 


CSV to XML Conversion

You can convert csv files to xml files using the following Perl script:

use DBI;
use File::Basename;

use strict;

my $dir   = '.';
my $file  = 'foo.csv';
my $table = (fileparse($file,'.csv'))[0];
my $cols  = [qw(name id date)];
my $sep   = ',';

my $dbh = DBI->connect(
   "DBI:CSV:f_dir=$dir;csv_eol=\n;csv_sep_char=$sep;",
   {RaiseError=>1},
);

$dbh->{csv_tables}->{$table} = { 
   file      => $file,
   col_names => $cols,
};

my $xml = My::DBIx::XML_RDB->new($dbh);
$xml->DoSql("select * from $table");
print $xml->GetData();


package My::DBIx::XML_RDB;
use base qw(DBIx::XML_RDB);

sub Initialise {
   my ($self,$dbh) = @_;

   $self->{dbh} = $dbh;
   $self->{output} = qq|&lt;?xml version="1.0"?>\n<DBI>\n|;

   return 1;
}

 


Lawson CSV Files

Comma-Separated Value (CSV) files can be created from database tables using rngdbdump. To load data back in, use importdb.

You can export all, or a portion, of a report to a CSV file by running:

  1. Print Manager (prtmgr)
  2. <F8> | Send to screen
  3. Put cursor on desired data detail item
  4. Choose <F8> (Send) | CSV file | All Data

If exporting a large print file to csv format, make sure to wait until the word Done appears at the bottom of the screen, otherwise you may experience data loss.

Since no error messages are written to the screen or the logs if records are skipped, it is a good idea to verify record counts by comparing the CSV file line count against the line count of the report from which the data was derived.

Keep the path to your csv file short. Print Manager has a character-length limit for PATH names.


Home