× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



If you were to use Python, you could use the xlsxwriter package and build
an actual Excel file and not worry about CSV.

First, install xlsxwriter:

$ pip3 install xlswriter

Then use something like this:

from xlsxwriter import Workbook
import ibm_db_dbi as db2

conn = db2.connect()
cur = conn.cursor()

query = "select * from qiws.qcustcdt"
filename = "qcustcdt.xlsx"

with Workbook(filename) as workbook:
cur.execute(query)
worksheet = workbook.add_worksheet()

headers = [descr[0] for descr in cur.description]
worksheet.write_row('A1', headers)

for rownum, row in enumerate(cur, start=1):
worksheet.write_row(rownum, 0, row)


"MIDRANGE-L" <midrange-l-bounces@xxxxxxxxxxxx> wrote on 11/16/2016
09:16:34 AM:

From: John Yeung <gallium.arsenide@xxxxxxxxx>
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx>
Date: 11/16/2016 09:17 AM
Subject: Re: Quoting text strings for SCV output
Sent by: "MIDRANGE-L" <midrange-l-bounces@xxxxxxxxxxxx>

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.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.