Beefy Boxes and Bandwidth Generously Provided by pair Networks
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 file

by Cristoforo (Curate)
on Jan 31, 2018 at 01:08 UTC ( [id://1208161]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Modifying an existing Perl script to ask for input and output filenames and also remove double quotes for outfile file
in thread Modifying an existing Perl script to ask for input and output filenames and also remove double quotes for outfile file

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} ]);.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1208161]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-03-29 07:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found