Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

how to print commas in csv

by loki (Novice)
on Jan 04, 2010 at 09:21 UTC ( #815546=perlquestion: print w/replies, xml ) Need Help??
loki has asked for the wisdom of the Perl Monks concerning the following question:

hi,i have an Excel sheet and am able to convert it into .csv format using Perl Parse::Excel. My only problem is that some of my data in the Excel sheet cells contain commas and that has to be retained in the CSV format also, but while converting it takes as a seperator. How can I retreive the data in the cell with commas as it is and print it in the CSV?

For example, in the Excel sheet A1 cell contains the data {0xAAAA,0xFFFF,0xAAAA,0xAAAA} I want the same data with commas in the A1 cell in CSV file also. I am using Spreadsheet::ParseExcel.

Replies are listed 'Best First'.
Re: how to print commas in csv
by Corion (Pope) on Jan 04, 2010 at 09:33 UTC

    How to retain commas in CSV is a question of how your receiving program parses the CSV. I'd use Text::CSV to write the CSV, then it will write the files mostly like Excel would, using double quotes to denote strings.

      Yup, I agree here.

      Another possibility is if the receiving program can define its separator to use a different character to comma not found in the data. (I like TAB).

        I love TAB so much that i have this in my .vimrc:
        """""""" "" Rotate tabstop value between 2, 4, 8, 16, 32 and 64 "" Mapped to <F2> "" function FDO_TabToggle () let TabStopVal = &tabstop let TabStopVal = TabStopVal * 2 if TabStopVal > 64 let TabStopVal = 2 endif let &tabstop = TabStopVal echo"TabStop is now: " TabStopVal endfunction

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://815546]
Approved by broomduster
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2018-06-17 23:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (107 votes). Check out past polls.

    Notices?