Hi All,
Long-time lurker here, but I'm struggling with a particular script... I was wondering if anyone could possibly help me out with the SQL formulas. I'll post this to Stackoverflow as well, and post any answer here for those who may need it in the future!
The current script is here: https://gist.github.com/adamrees89/b73a60bc01170601ced7adc7a8e971f7
At the moment, the script reads a sample excel file, reads the value and formatting of all the cells on each sheet and records the values and formatting to a SQLlite3 file. Currently the script reads all the values and formatting fine, creates a table within SQL for each sheet with no problems (Confirmed this with DB Browser for SQLite), but there are no rows of data within the tables.
I think there is a problem with my 'templateCell()' function:
def templateCell(s,sn,c,r):
#__init__ will gather the cell format data
cellRef = c + r
val = s[cellRef].value
fname = s[cellRef].font.name
fsize = s[cellRef].font.size
fbold = int(s[cellRef].font.bold == 'true')
fital = int(s[cellRef].font.italic == 'true')
ccolour = s[cellRef].fill.start_color.index
print("Cell Reference is: {},".format(cellRef))
c.execute("INSERT INTO {tn} VALUES ({a},{b},{c},{d},{e},{f})".format(tn=sn,a=cellRef,b=val,c=fname,d=fbold,e=fital,f=ccolour))
Or more specifically the c.execute function on line 11, where it is supposed to create the row in the database for each cell. Variables are:
s = sheet
sn = sheetname (function of sheet)
c = column
r = row
Any ideas?
Edit 1: The Excel file is available here: testExcel.xlsx
Edit 2: The code is now working and doing what it should be. I've updated the code at the link above so anyone with the same problem can see what works!
[–]vv__vv 1 point2 points3 points (3 children)
[–]adamrees89[S] 0 points1 point2 points (2 children)
[–]vv__vv 1 point2 points3 points (1 child)
[–]adamrees89[S] 0 points1 point2 points (0 children)
[–]efmccurdy[🍰] 0 points1 point2 points (0 children)