Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Re: Re: How can I read a file that is comma delimited but includes a comma in the string?

by Ovid (Cardinal)
on May 28, 2003 at 00:13 UTC ( #261144=note: print w/replies, xml ) Need Help??


in reply to Re: Re: How can I read a file that is comma delimited but includes a comma in the string?
in thread How can I read a file that is comma delimited but includes a comma in the string?

Directly from the POD of Text::CSV_XS:

require Text::CSV_XS; my $csv = Text::CSV_XS->new; my $column = ''; my $sample_input_string = '"I said, ""Hi!""",Yes,"",2.34,,"1.09" +'; if ($csv->parse($sample_input_string)) { my @field = $csv->fields; my $count = 0; for $column (@field) { print ++$count, " => ", $column, "\n"; } print "\n"; } else { my $err = $csv->error_input; print "parse() failed on argument: ", $err, "\n"; } my @sample_input_fields = ('You said, "Hello!"', 5.67, 'Surely', '', '3.14159'); if ($csv->combine(@sample_input_fields)) { my $string = $csv->string; print $string, "\n"; } else { my $err = $csv->error_input; print "combine() failed on argument: ", $err, "\n"; }

Cheers,
Ovid

New address of my CGI Course.
Silence is Evil (feel free to copy and distribute widely - note copyright text)

  • Comment on Re: Re: Re: How can I read a file that is comma delimited but includes a comma in the string?
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://261144]
help
Chatterbox?
[Discipulus]: I havery limited needs in such field. Sometimes (for children party invitations) i draw something by hand and I scan it to include into an ms doc.
Discipulus havery can be a good neologism for: have very..;=)
[ambrus]: Discipulus: sure, it's just that, look, some people (including me) have such unreadable and slow handwriting that writing an article or slides by hand would be a very bad idea.
[choroba]: it might bery useful for other verbs, too
[ambrus]: (and I have a need for at least decent formatting too)

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2017-09-26 11:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (293 votes). Check out past polls.

    Notices?