I have recently created a GUI, which contents tables. User can insert values in cells. As shown figur below.
I want to use values to make some calculation based on values given by user. Rows can be added and removed based on choice of user. with other word, the data I get from user could come from just one row or several rows.
I manage to obtain all values from tables automatically and assign them to python list. Each row gives 5 elements in the list.
I have achieved that. Data in python list have to be processed and organised. This is exactly I want to have help. Because few dags I have been thinking, and I can not figure out, how to continue...
Python data as list from table. as an example.
data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, '', 11, 12, 13, 14]
What I want to achieve!
I want to split list into 3 times len(data)
.
I have also achieved this.
def split_seq(seq, num_pieces):
start = 0
for i in range(num_pieces):
stop = start + len(seq[i::num_pieces])
yield seq[start:stop]
start = stop
for data in split_seq(data, int(len(data)/5)):
print(data)
Output would be:
[1, 2, 3, 4, 5]
[6, 7, 8, 9, 10]
['', 11, 12, 13, 14]
The difficulty for me starts here.
I want to take each splitted list and throw them into a if condition and store values as variables and message those values to a external function.
Something like this below:
for i in range(len(splitted_list1)):
if splitted_list1[0] == '':
do nothing
else:
x_+str(i)= splitted_list1[i]
externalfunc(x_1,x_2,x_3,x_4,x_5)
for i in range(len(splitted_list2)):
if splitted_list2[0] == '':
do nothing
else:
x_+str(i)= splitted_list2[i]
externalfunc(x_1,x_2,x_3,x_4,x_5)
continues depending on number of splitted_lists
..............
I appreciate any help and you are welcome to come with another idea to come around this.
Aucun commentaire:
Enregistrer un commentaire