Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Converting a delimited file.

by Laurent_R (Canon)
on May 20, 2015 at 20:19 UTC ( [id://1127277]=note: print w/replies, xml ) Need Help??


in reply to Converting a delimited file.

Hi insta.gator

we are using a lot of CSV format at our job. Most of the time, we can control both the generation of the CSV file in one application and its later use in another application. So we can use a very simple CSV format (ASCII characters, no quotes, no escape char, almost always the same separator, etc.), and we are happily using join and split to generate and decypher our CSVs. It can really make coding very simple. For example, just today, I wrote a line of code looking like this:

my $err_code = (split /;/, $line)[8];
I only needed that field 8 of every line to decide what to do with this line, it is really great to be able to do it in just one code line. The other programming language from which I was translating the code to Perl needed, if I remember right, 4 or 5 lines of code.

But some of our partners sometimes send us more complicated CSV files, with quote and escape characters, and so on, then, really, using the Text::CSV module is handy and is really, IMHO, the right way to go.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (7)
As of 2024-04-18 08:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found