I built a UI on Linux and the exact same code works just fine on Linux but this portion of the code throws an error:
Traceback (most recent call last):
File "C:\Users\sukhd\OneDrive\Desktop\projectBFC\BFCsource.py", line 169, in <module>
main()
File "C:\Users\sukhd\OneDrive\Desktop\projectBFC\BFCsource.py", line 164, in main
form = MainWindow()
File "C:\Users\sukhd\OneDrive\Desktop\projectBFC\BFCsource.py", line 21, in __init__
self.convertCSVtoDB()
File "C:\Users\sukhd\OneDrive\Desktop\projectBFC\BFCsource.py", line 95, in convertCSVtoDB
(col1, col2, col3, col4, col5) = line.split(';')
ValueError: not enough values to unpack (expected 5, got 1)
>>>
I can't seem to understand why this error comes up when I've tested this on Linux and it works just as intended.
def convertCSVtoDB(self):
self.sortBroker()
conn = sqlite3.connect('brokers.db')
cur = conn.cursor()
cur.execute('DELETE FROM Brokers')
#cur.execute('''CREATE TABLE Brokers(CompanyName text,StreetAddress text,CityZIP text ,Telephone text,Email text)''')
myData = []
with open("sortedBrokers.csv") as f:
# line = testName;testAddress;testZip,State;testphone;testemail
for line in f.readlines():
line = line.rstrip('\n')
(col1, col2, col3, col4, col5) = line.split(';')
mytuple = (col1, col2, col3, col4, col5)
myData.append(mytuple)
with conn:
cur.executemany('INSERT into Brokers (CompanyName,StreetAddress,CityZIP,Telephone,Email) VALUES (?,?,?,?,?)', myData)
cur.execute("SELECT * FROM Brokers")
results = cur.fetchall()
self.CB_brokers.clear()
for broker in range(len(results)):
self.CB_brokers.addItem(str(results[broker][0]))