-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathListSplit_gui.py
58 lines (54 loc) · 1.33 KB
/
ListSplit_gui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
global bookname
global authorname
global quantity
global cost
global totalcost
global book
global count1
bookname=[]
authorname=[]
quantity=[]
cost=[]
book=[]
totalcost=0
count1=0
def listSplit():
global bookname
global authorname
global quantity
global cost,totalcost
bookname=[]
authorname=[]
quantity=[]
cost=[]
book=[]
totalcost=0
global count1
count1=0
t=0
with open("F:\python projects\LMS\Stock.txt","r") as f:
#creating a list of lines in stock.txt
lines=f.readlines()
#removing \n from list
lines=[x.strip('\n') for x in lines]
#fetching each element one by one
for i in range(len(lines)):
ind=0
#splitting one element of list into multiple elements
for a in lines[i].split(','):
if(ind==0):
bookname.append(a)
count1=count1+1
elif(ind==1):
authorname.append(a)
elif(ind==2):
quantity.append(a)
elif(ind==3):
cost.append(a.strip("Rs"))
totalcost+=int(a.strip("Rs"))
ind+=1
book.append(bookname)
book.append(authorname)
book.append(quantity)
book.append(cost)
return book