Skip to content
Snippets Groups Projects
Commit 282f2433 authored by Recolic Keghart's avatar Recolic Keghart
Browse files

bug fix: fucking python num conv error

parent 074c85fe
No related branches found
No related tags found
No related merge requests found
......@@ -4,10 +4,22 @@ import csv, io
def xlsx2csv(xlsxPath, sheetIndex, outputFd):
wb = xlrd.open_workbook(xlsxPath)
sh = wb.sheet_by_index(sheetIndex)
wr = csv.writer(outputFd, quoting=csv.QUOTE_NONNUMERIC)
wr = csv.writer(outputFd, quoting=csv.QUOTE_MINIMAL)
def fuck_number_ele(ele):
if type(ele) is float:
s = str(ele)
if 'e' in s.lower():
raise RuntimeError('Fuck python Float2Str: THIS IS A BUG. PLEASE REPORT.')
if s.endswith('.0'):
return s[:-2]
else:
return s
else:
return ele
for rownum in range(sh.nrows):
wr.writerow(sh.row_values(rownum))
wr.writerow([fuck_number_ele(ele) for ele in sh.row_values(rownum)])
def read_as_csv(fname):
is_xlsx = lambda fname: fname.endswith('.xlsm') or fname.endswith('.xlsx') or fname.endswith('.xls') or fname.endswith('.XLSM') or fname.endswith('.XLSX') or fname.endswith('.XLS')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment