Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re^2: to csv file

by Anonymous Monk
on Jun 29, 2013 at 07:41 UTC ( #1041411=note: print w/ replies, xml ) Need Help??

in reply to Re: to csv file
in thread to csv file

i am sorry it was a mistake , i want them as one

Comment on Re^2: to csv file
Replies are listed 'Best First'.
Re^3: to csv file
by poj (Vicar) on Jun 29, 2013 at 07:52 UTC

    One way is to take advantage of excel's ability to open tab delimited text files with .xls extension

    #!perl use strict; open OUT,">test.xls" or die "$!"; while (<DATA>){ s/;;/\t/g; print OUT; } close OUT; __DATA__ abd;;sasa;;trre,dsa;;sdas;;dsss abd;;sasa;;trre,dsa;;sdas;;dsss abd;;sasa;;trre,dsa;;sdas;;dsss
      hey the thing is i need the output as csv , because it is an input to other sub routine
        I would change the other routine, but anyway, a simple solution would be double quote all the fields regardless.
        #!perl use strict; open OUT,">test.csv" or die "$!"; while (<DATA>){ chomp; s/;;/","/g; print OUT '"'.$_.'"'."\n"; } close OUT; __DATA__ abd;;sasa;;trre,dsa;;sdas;;dsss abd;;sasa;;trre,dsa;;sdas;;dsss

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (13)
As of 2015-11-30 09:06 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (767 votes), past polls