There's more than one way to do things | |
PerlMonks |
Re^3: Modifying an existing Perl script to ask for input and output filenames and also remove double quotes for outfile fileby Cristoforo (Curate) |
on Jan 31, 2018 at 01:08 UTC ( [id://1208161]=note: print w/replies, xml ) | Need Help?? |
I agree much with you Grandfather, however he stated in his post-
When I run the script on my input.csv file the output.csv file which is created by the script has double quotes in two of the data columns, i.e. the Timestamp field "2018-01-23 00:00" and the ProdDescription field "Acme Widget Large 20 inch" These double quotes need to be removed to comply with the required data format of the final csv file.So I don't know if he sends the result somewhere, they will be able to parse a proper CSV file. Needed additions/changes to the script to make it proper would be: Add use Text::CSV; in the header with the other use statements. Create a new csv object, my $csv = Text::CSV_XS->new({binary => 1, eol => $/}); before the while loop. Instead of the print statement, use $csv->print($out, [ @tmp{@cols} ]);.
In Section
Seekers of Perl Wisdom
|
|