olemb / dbfread

Read DBF Files with Python
MIT License
223 stars 91 forks source link

Throwing exceptions if column name contains commas #58

Open rumblerina opened 3 years ago

rumblerina commented 3 years ago

I'm trying to make a python code for converting a .dbf file into an .xlsx file, but it throws an exception (with the name of a column in question, which doesn't make me understand it any better) when the column name has a comma. It doesn't throw one if it doesn't though:

from openpyxl import Workbook, load_workbook
from dbfread import DBF

wb = Workbook()
table = DBF("DBRADON.DBF", load = True, ignore_missing_memofile=True)
length = len(table)
ws1 = wb.create_sheet("RFD", 0)
ws2 = wb.create_sheet("RAC")
ws1['A1'] = "Date"
ws1['E1'] = "Measurement Start"
ws1['F1'] = "Measurement End"
ws1['G1'] = "Exposition Length"
ws1['H1'] = "Measurement Length"
ws1['I1'] = "Radon activity"
ws1['J1'] = "Radon activity +-"
ws1['K1'] = "RFD"
ws1['L1'] = "RFD+-"
ws1['O1'] = "SK-13"
E = []
for e in range(2, len(table)):
    E.append('E' + str(e))

#print(table.records[12]['A214BI']) #This doesn't throw an exception
#print(table.records[12]['BGTM,N,2,0']) #This throws an exception

wb.save('radon.xlsx')

File in question is attached: DBRADON.zip