On Wed, Nov 16, 2016 at 8:11 AM, Don Brown <DBrown@xxxxxxxxxx> wrote:
I have a requirement to produce a csv file with all text strings double
quoted.
Can you guarantee that the textual data doesn't itself contain
double-quotes? If not, then how are they supposed to be handled?
My first question is does anyone have a method to generate an excel
spreadsheet either .xls or .xlsx that can then be saved as a csv file that
will include double quotes around text cells ?
There isn't a way to create such a CSV via Excel. If Excel is
involved, it will only put quotes around text fields that contain
characters which need to be escaped (the ones I know of are comma,
double-quote, and newline).
Appreciate any suggestions
First and foremost, I personally think the most important thing is to
really understand the requirements. For example, why do you need the
double-quotes around all text fields, and what happens if the field
itself contains a double-quote? (These are only some of the questions
I would have. I would definitely want to know more.) And yes, I'm sure
these requirements are imposed on you by some third party, but I would
want to know from them how exactly they are processing the CSV.
If you truly have a thorough understanding of the exact requirements,
and all the possible corner cases and pitfalls, then you're ready to
write your output directly to IFS as a stream file in your desired
format.
I know I'm shoehorning this in, but if you're willing to use Python,
that would make things much easier. You could either use Python as a
soup-to-nuts solution (including pulling together the data, doing the
calculations, and outputting to CSV), or just as a postprocessor
(accepting either an Excel workbook or an Excel-generated CSV, and
writing out the desired variant of CSV). I imagine there are several
other technologies that are "comparably easy" as Python for this task,
but I have not used them and thus cannot vouch for them.
John Y.
As an Amazon Associate we earn from qualifying purchases.