Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^6: Text to CSV with user input comma

by shushant (Novice)
on Jun 28, 2013 at 08:37 UTC ( [id://1041180]=note: print w/replies, xml ) Need Help??


in reply to Re^5: Text to CSV with user input comma
in thread Text to CSV with user input comma

yes pretty much , but what I have done is replaced the commas of text file to a delimiter as ;; , so that i can split it using ;; , and even if there is a comma in file it would not affect it

input looks like 50;; C,nt ;; ;;8;; 1;; ds;; 1;; a;; 1;; 0;; 0;; ;; ;; ;; output looks like " 50"," C ,nt "," ",8," 1","ds","1"," Va"," 1"," 0"," 0"," "," "," " and I just want these " " to get omitted

 push @rows, [ split m{ ;; }msx, $line ]; I have done this in the code

Replies are listed 'Best First'.
Re^7: Text to CSV with user input comma
by hdb (Monsignor) on Jun 28, 2013 at 08:56 UTC

    Well, the double quotes are being inserted to be able to distinguish between the comma as a field separator and the comma within the fields, eg " C ,nt ". If you write the data to file without them, then you lose this ability.

    If that is really what you desire, then something like print $out_fh join ",", @$row; might work better for you than using Text::CSV. However, I cannot really imagine why this would be useful...

    UPDATE: ...or use

    $csv = Text::CSV->new ({ quote_char => undef });

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (2)
As of 2024-04-26 01:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found