Skip to content

Commit

Permalink
Quote all non numeric fields execpt for the header line.
Browse files Browse the repository at this point in the history
  • Loading branch information
bgol committed Nov 2, 2014
1 parent a5f62c0 commit 637e138
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions misc/gen_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def exportTables(dbFilename, exportPath, exportTable=None, quiet=True, debug=0):
reverseList = [ 'AltItemNames',
'Item',
'Price',
'PriceHistory',
'ShipVendor',
'Station',
'UpgradeVendor'
Expand All @@ -70,7 +69,7 @@ def exportTables(dbFilename, exportPath, exportTable=None, quiet=True, debug=0):
# create CSV files
if not quiet: print("Export Table '{table}' to '{file}'".format(table=tableName, file=exportName))
with exportName.open("w") as exportFile:
exportOut = csv.writer(exportFile, delimiter=",", quotechar="'", doublequote=True, lineterminator="\n")
exportOut = csv.writer(exportFile, delimiter=",", quotechar="'", doublequote=True, quoting=csv.QUOTE_NONNUMERIC, lineterminator="\n")

cur = conn.cursor()
keyList = []
Expand Down Expand Up @@ -130,7 +129,8 @@ def exportTables(dbFilename, exportPath, exportTable=None, quiet=True, debug=0):

# finally generate the csv file
lineCount = 0
exportOut.writerow(csvHead)
# no quotes for header line
exportFile.write("{}\n".format(",".join(csvHead)))
for line in cur.execute(sqlStmt):
lineCount += 1
exportOut.writerow(list(line))
Expand Down

0 comments on commit 637e138

Please sign in to comment.