NAME

SAS::TRX::CY - Convert a TRX library into a YAML description and CSV data.

SYNOPSIS

use SAS::TRX::CY;

my $cy = new SAS::TRX::CY DATASET=>'trx.csv', STRUCT=>'trx.yml';
$cy->load('source.trx');

DESCRIPTION

Parses 'source.trx' and splits onto DATASET and STRUCT files. Make sure you have write access permission to the destination files.

YAML defines data types in TRX terms: --- TABLE_NAME: - LABEL: column1 label NAME: column1 name TYPE: CHAR or NUMBER - LABEL: column2 label NAME: column2 name TYPE: CHAR or NUMBER

To determine needed column length and distinguish INTEGER and FLOAT, use SAS::TRX::MySQL or SAS::TRX::SQLite.

Each line in CSV file ends with '+' to describe the structure in the following section or '-' to indicate actual data rows. The '+' line contains the table name followed by column names.

Thus the CSV parser may be like this:

    my ($tbl, @cols, %data);
    while (<>) {
	chomp;
	my $tag = chop;
	if ($tag eq '+') {
	    ($tbl, @cols) = split;
	    next;
	} elsif ($tag eq '-') {
	    @data{@cols} = split;
	    next;
	} else {
	    die 'Format violation';
	}
    }

EXPORT

Nothing is exported.

SEE ALSO

SAS::TRX for the base class
SAS::TRX::MySQL, SAS::TRX::SQLite for data types

AUTHOR

Alexander Kuznetsov, <acca (at) cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2009 by Alexander Kuznetsov

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.