| … | |
… | |
| 28 | push @result, [split m/\s*,\s*/, $column]; |
28 | push @result, [split m/\s*,\s*/, $column]; |
| 29 | } |
29 | } |
| 30 | return @result; |
30 | return @result; |
| 31 | } |
31 | } |
| 32 | |
32 | |
|
|
33 | # Write a CSV file from an array in the same format that readCSV produces |
| 33 | sub writeCSV { |
34 | sub writeCSV { |
| 34 | my ($self, $filename, @csv) = @_; |
35 | my ($self, $filename, @csv) = @_; |
| 35 | open my $fh, ">", $filename; |
36 | open my $fh, ">", $filename; |
| 36 | foreach my $column (@csv) { |
37 | foreach my $column (@csv) { |
| 37 | my $maxLength = $self->maxLength($column); |
38 | my $maxLength = $self->maxLength($column); |
| … | |
… | |
| 39 | print "\n"; |
40 | print "\n"; |
| 40 | } |
41 | } |
| 41 | close $fh; |
42 | close $fh; |
| 42 | } |
43 | } |
| 43 | |
44 | |
|
|
45 | # As soon as backwards compatability is no longer a concern and we don't expect to have |
|
|
46 | # to use old ww1.x code to read the output anymore, I recommend switching to using |
|
|
47 | # these routines, which are more versatile and compatable with other programs which |
|
|
48 | # deal with CSV files. |
| 44 | sub readStandardCSV { |
49 | sub readStandardCSV { |
| 45 | my ($self, $filename) = @_; |
50 | my ($self, $filename) = @_; |
| 46 | my @result = (); |
51 | my @result = (); |
| 47 | my @colunms = split m/\n/, readFile($fileName); |
52 | my @colunms = split m/\n/, readFile($fileName); |
| 48 | foreach my $column (@columns) { |
53 | foreach my $column (@columns) { |