Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: to csv file

by poj (Abbot)
on Jun 29, 2013 at 07:52 UTC ( [id://1041414]=note: print w/replies, xml ) Need Help??


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

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
poj

Replies are listed 'Best First'.
Re^4: to csv file
by Anonymous Monk on Jun 29, 2013 at 07:56 UTC
    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
      poj

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-18 14:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found