-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatement_hdfc.py
More file actions
33 lines (31 loc) · 1.17 KB
/
Copy pathstatement_hdfc.py
File metadata and controls
33 lines (31 loc) · 1.17 KB
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
import xlrd, re, json
workbook = xlrd.open_workbook('hdfcstatement.xls')
workbook = xlrd.open_workbook('hdfcstatement.xls', on_demand = True)
worksheet = workbook.sheet_by_index(0)
first_row = []
for col in range(worksheet.ncols):
for sheet in workbook.sheets():
for rowidx in range(sheet.nrows):
row = sheet.row(rowidx)
for colidx, cell in enumerate(row):
if cell.value == "Date" :
first_row.append( worksheet.cell_value(rowidx,col) )
data_preview =[]
for sheet in workbook.sheets():
for rowidx in range(sheet.nrows):
row = sheet.row(rowidx)
for colidx, cell in enumerate(row):
if cell.value == "Date" :
for row in range(rowidx+1, worksheet.nrows):
elm = {}
for col in range(worksheet.ncols):
elm[first_row[col]]=worksheet.cell_value(row,col)
data_preview.append(elm)
data=[]
for x in data_preview:
check = re.search(r'(\d+/\d+/\d+)', str(x['Date']))
if check:
data.append(x)
with open('result_hdfc.json', 'w') as f:
json.dump(data, f)
print(data, len(data))