Apr-01-2019, 05:04 PM
Thank you Larx60+ for relocating this where I should have put it.
I have delved into this further to see if I can get a solution..
Method 2: Prints out the first item from the .csv file and does not print any more lines.
The tuple misses the first line from the .csv file but gets picks up all the rest of the items.
Method 1: Using a tuple and a list to allow me to append each row to the list before converting back to a tuple.
Not very subtle but it works for the meantime.
I can't believe that there is not a better solution but my inexperience can't take me beyond this at the moment.
Another point that I note and need to understand is this: If I have any white space between words in the .csv for example "DADMIN Database Admin" when this is loaded into the combobox we get {DADMIN Database Admin} as the combobox selection. If we have other elements in the .csv such as "PIPING" or "ELEC" these appear as normal selections without the curly brackets, another riddle to solve.
I haven't thought to check on syntax within the brackets following the OPEN statement for example newline = '' etc.
I have delved into this further to see if I can get a solution..
Method 2: Prints out the first item from the .csv file and does not print any more lines.
The tuple misses the first line from the .csv file but gets picks up all the rest of the items.
Method 1: Using a tuple and a list to allow me to append each row to the list before converting back to a tuple.
Not very subtle but it works for the meantime.
I can't believe that there is not a better solution but my inexperience can't take me beyond this at the moment.
Another point that I note and need to understand is this: If I have any white space between words in the .csv for example "DADMIN Database Admin" when this is loaded into the combobox we get {DADMIN Database Admin} as the combobox selection. If we have other elements in the .csv such as "PIPING" or "ELEC" these appear as normal selections without the curly brackets, another riddle to solve.
I haven't thought to check on syntax within the brackets following the OPEN statement for example newline = '' etc.
# METHOD 1 use LIST and TUPLE TO obtain data from .csv file with open('MAIN.csv', newline='') as csvfile: spamreader = csv.reader(csvfile , delimiter='"') Tup1 = () Lst1 = () for row in spamreader: print(','.join(row)) Lst1 = list(Tup1) Lst1.append(row) Tup1 = tuple(Lst1) # METHOD #2 # with open('MAIN.csv', newline='') as csvfile: # spamreader = csv.reader(csvfile , delimiter=',') # Tup1 = () # for row in spamreader: # print(','.join(row)) # Tup1 = [tuple(row)for row in spamreader] ComboGrp1 = ttk.Combobox(window, width = 30, height = 20) ComboGrp1.place(x = 500 , y = 110) # Hard code the values #ComboGrp1['values']=('Test1','Test2','Test3') ComboGrp1['values']=(Tup1) ComboGrp2 = ttk.Combobox(window, width = 10, height = 20) ComboGrp2.place(x = 500 , y = 130)I'd appreciate if anyone can shed light on these two questions.