Skip to content

Commit

Permalink
with calamine
Browse files Browse the repository at this point in the history
  • Loading branch information
Guy-Galil committed Aug 29, 2024
1 parent 2644e7f commit 3bba274
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
3 changes: 2 additions & 1 deletion djang/importer/management/commands/import_single_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def add_arguments(self, parser):
parser.add_argument("file", type=str)

def handle(self, *args, **options):
filename="/home/guyga/hasadna/penssion/xlsx-files/files/512065202_p12157_p120.xlsx"#options["file"]
filename="/home/guyga/hasadna/penssion/xlsx-files/bad/רשימת נכסים ברמת נכס בודד- Public - מסלול פנסיה-2020 רבעון 1-איילון מיטב כללית מסלול מניות.xlsx"
#"/home/guyga/hasadna/penssion/xlsx-files/files/12065202_p12157_p120.xlsx"#options["file"]
m=options["mode"]
ingester = xsls_ingester.xls_ingester()
with io.open(filename, "rb") as file:
Expand Down
19 changes: 9 additions & 10 deletions djang/importer/services/xsls_ingester.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


class xls_ingester(object):
force = False
force = True
file = None
wb = None
with open(MAPPING_FILE) as json_data:
Expand All @@ -38,9 +38,9 @@ def find_sn(self, wb):
for tab in self.mapping:
sn = tab["tab_name"]
if sn != "any":
self.parse_first_tab(wb, sn, tab)
sheet_name_array.remove(sn)
ws = wb[sn]
sn2 = self.parse_first_tab(wb, sn, tab)
sheet_name_array.remove(sn2)
ws = wb[sn2]
fields = tab["fields"]
for field in fields:
if field["type"] == "generated":
Expand Down Expand Up @@ -89,7 +89,7 @@ def getSheet(self, wb, sn):
if sn1 in wb:
sn2 = sn1
break
return wb[sn2]
return wb[sn2] , sn2

def parse_first_tab(self, wb, sn, tab):
# from first tab get report date, company, track name and track code
Expand All @@ -99,7 +99,7 @@ def parse_first_tab(self, wb, sn, tab):
if field["type"] == 'generated':
continue
else:
worksheet = self.getSheet(wb, sn)
worksheet, sn2 = self.getSheet(wb, sn)
if worksheet is not None:
for row in worksheet.iter_rows(min_row=1, max_row=4, max_col=4, values_only=False):
for cell in row:
Expand All @@ -115,8 +115,7 @@ def parse_first_tab(self, wb, sn, tab):
found = True
i = 1
for i in range(1, 4):
val = wb[sn2].cell(
row=cell.row, column=cell.column+i).value
val = worksheet.cell(row=cell.row, column=cell.column+i).value
if val is not None:
self.reference_objects = self.put_in_model(
self.reference_objects, field1, val)
Expand All @@ -128,7 +127,7 @@ def parse_first_tab(self, wb, sn, tab):
break
self.save_first_tab()

return
return sn2

def save_first_tab(self):
# if kupa exists
Expand Down Expand Up @@ -334,7 +333,7 @@ def ingest(self, filename, file_stream):
return True
except ValueError:

#traceback.print_exc()
traceback.print_exc()
print("report already exists")
return False

Expand Down

0 comments on commit 3bba274

Please sign in to comment.