Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Help with CSV file parsing

by chrism01 (Friar)
on Aug 05, 2008 at 07:46 UTC ( [id://702262]=note: print w/replies, xml ) Need Help??


in reply to Help with CSV file parsing

Here's an easier way:
$var1 = 'a, a"s"d, 123'; @arr = split(/,/, $var1); print "@arr\n";
You'll want the dbh->quote() method: http://search.cpan.org/~timb/DBI-1.607/DBI.pm#quote

Cheers
Chris

Replies are listed 'Best First'.
Re^2: Help with CSV file parsing
by NOTSomebody (Initiate) on Aug 05, 2008 at 08:15 UTC
    Hi Chris, thanks for your reply. I understand your point but just that I am trying to read only the double quote. If the text contains other special characters, I will need to read also...

    Like
    $var1 = 'a, a"s,d,f,g", 123'

    Then the result I want will be:
    Insert into person_info VALUES (a, a"s,d,f,g", 123)

    Currently I can read every character without taking it out from the part of the text but if there is double quotes within the data, my generated SQL statements will be sort of screwed.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2024-04-25 06:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found