It's true that Text::CSV does not directly handle multiline fields, but I found it quite easy to get around
My task was to export/import a set of requirements between tools, for which purpose I (amongst others) needed to add a field and sort the input recursively by parent reference (using
Sort::Naturally)
On reading, I created multilines as
while ( my $line = $csv->getline($fh) ) {
# Manipulation of unsorted fields during import
my @multiline = join(';',@{$line});
push @content, @multiline ;
}
if (not $csv->eof) {
$csv->error_diag();
}
and on printing back, I entered data field by field as
for my $line (@result) {
my @fields = split(/;/,$line);
# Manipulation of sorted fields during export
print $fh "$_;" foreach @fields;
print $fh "\n";
}
with csv object created as
$csv = Text::CSV->new({ binary => 1, auto_diag => 1, sep_char => ';' });
I.e. I never bothered to try using the module for writing back data, nor other suggestions as from above :)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
|
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.