-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequired_data.py
More file actions
45 lines (31 loc) · 873 Bytes
/
required_data.py
File metadata and controls
45 lines (31 loc) · 873 Bytes
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
import pandas as pd
import xlrd
#This program will take the required data from the data sent from the placement cell and store it in the csv file
list = [ 2, 7, 8, 12, 13, 14, 15, 16, 17, 18, 19, 21, 44, 45, 46, 55, 56, 57 ]
mainlist = []
def store_values(a, result):
re = []
for i in list:
try:
re.append(str(a[i]))
except:
re.append(0)
re.append(result)
return re
filename = raw_input("Enter the file")
output = raw_input("Enter the csv file where it should be stored")
wb = xlrd.open_workbook(filename)
sh = wb.sheet_by_name('CSE')
for rownum in xrange(sh.nrows):
a = sh.row_values(rownum)
if a[4]=='' and a[5]=='':
result = 0
else:
result = 1
re = store_values(a, result)
mainlist.append(re)
apple = mainlist.pop(0)
apple[-1] = 'final_result'
df = pd.DataFrame(mainlist, columns = apple)
df.to_csv(output, sep=',')
print 'done'