I need to read in a CSV file, do some munging, and write out the alterations to a new CSV file. I'd like to use Text::CSV for this, but the problem is this particular CSV file uses double-quotes only around fields it has defined as "text fields" (although the contents of a particular text field may actually be a number). To make matters worse, the fields can change from one line to the next. (Actually, I have file layouts that would help me determine which lines are going to have which field definitions, but if possible, I'd like to find a "generic" solution that will work with other files from this same application.)
So, I may need to read in lines like:
and write them out as"hi",3,20.6,"green","32" 16,"alpha",0.00
As far as I can tell, Text::CSV can handle all of this except writing out with quotes the way I need. It either writes everything with quotes or nothing. For my purposes, if the field had quotes coming in, it needs quotes going out."bye",3,27.6,"green","32" 16,"beta",0.00
I don't want to write my own CSV parser for this. Can I still use Text::CSV somehow, or is there another perlish solution?
-E
In reply to Writing CSV files by EyeOpener
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |