Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: lightweight CSV parser

by Anonymous Monk
on Dec 22, 2011 at 07:50 UTC ( [id://944733]=note: print w/replies, xml ) Need Help??


in reply to lightweight CSV parser

Most of the Text:CSV type modules read from files, so I was unable to make them work with a string variable.

check the documentation again, because they all work with strings as well, anyway

open my($fh), '<' , \$stringOfCsv; ...

Replies are listed 'Best First'.
Re^2: lightweight CSV parser
by wrinkles (Pilgrim) on Dec 22, 2011 at 08:32 UTC
    That appears to be a filehandle reference, not a regular string. I actually tried initially to use YAML strings, and with YAML::Syck was able to get a prototype working by opening a string reference as a filehandle, then loaded with YAML::Syck::LoadFile($fh) . That was the only YAML parser that worked like that, and when I tried the same thing within Movable Type, it wouldn't read the filehandle. "No such file or directory -type errors. So I gave up.

    It looked simple, but I'm missing some key concept.

    Maybe parsing CSV is easier. I'll give it a try.

      That appears to be a filehandle reference, not a regular string ...

      Well, if you insist http://search.cpan.org/perldoc/Text::CSV#SYNOPSIS only works with files, that is how you treat a regular string ($stringOfCsv), as a filehandle

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-03-19 05:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found