Exportation impossible for python 3
vnahmias opened this issue · comments
vnahmias commented
Hello i noticed the exportation method doesn't work for python 3 and more, i have modified your file in order to make it work for both python2.7 and 3 :
def ExportTableData(self, table, sep=None):
"""Export table data to a comma separated file"""
parent=table.parentframe
filename = filedialog.asksaveasfilename(parent=parent,defaultextension='.csv',
filetypes=[("CSV files","*.csv")] )
if not filename:
return
if sep == None:
sep = ','
f=open(filename, "w")
writer = csv.writer(f,delimiter=sep)
model=table.getModel()
recs = model.getAllCells()
#take column labels as field names
colnames = model.columnNames
collabels = model.columnlabels
row=[]
for c in colnames:
row.append(collabels[c])
writer.writerow(row)
for row in recs.keys():
writer.writerow(recs[row])
f.close()
return
Damien Farrell commented
This appears to be just a single line bug. If it still doesn't work for you let me know.
hhaoao commented
@dmnfarrell hello,Python 3.6 has revoked string.lower
and it works fine after the fix.(I see the commit has been fixed (d18a8bd), but the latest branch is not submitted in pypi,I submitted a junk issues.)
def checkOSType(cls):
"""Check the OS we are in"""
ostyp=''
var_s=['OSTYPE','OS']
for var in var_s:
if var in os.environ:
try:
ostyp = string.lower(os.environ[var])
except AttributeError:
ostyp = os.environ[var].lower()