in reply to Re^2: splitting csv file and saving data
in thread splitting csv file and saving data
Hi BrowserUk,
I guess you are calling the third field "conditional"? The way I interpreted the input in the OP is a CSV file with four columns: layer name (string), layer number (integer), data types (string), and text type (integer). That the "data types" field was encoded as comma-separated integers in a string is certainly not an optimal design choice and it takes some manual decoding, but unless there's more the OP isn't telling us about the format, I disagree, this looks like CSV to me.
And BTW, I did test before posting (mostly a copy-and-paste from Text::CSV's synopsis):
use Data::Dump 'pp'; use Text::CSV; my $csv = Text::CSV->new ( { binary => 1 } ) or die "Cannot use CSV: ".Text::CSV->error_diag (); open my $fh, "<:encoding(utf8)", "Text_File.csv" or die $!; while ( my $row = $csv->getline($fh) ) { my @vals = split /,/, $row->[2]; pp $row, @vals; } $csv->eof or $csv->error_diag(); close $fh; __END__ ([" NPLUS", 32, 0, ""], 0) (["NW", 41, 0, 1], 0) (["NWER", 51, "0,1,2", "12 "], 0, 1, 2)
Regards,
-- Hauke D
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: splitting csv file and saving data
by BrowserUk (Patriarch) on Nov 03, 2016 at 11:45 UTC | |
by haukex (Archbishop) on Nov 03, 2016 at 12:52 UTC |