Add Alphawire datasheet fallback
This commit is contained in:
@@ -112,14 +112,14 @@ def parse(filename, output_dir, partnum, dstype):
|
||||
tables = dict()
|
||||
torename = dict()
|
||||
previous_table = ""
|
||||
print(table_list.keys())
|
||||
#print(table_list.keys())
|
||||
for table_name in table_list.keys():
|
||||
# determine shape: horizontal or vertical
|
||||
table = table_list[table_name]
|
||||
rows = table.shape[0]
|
||||
cols = table.shape[1]
|
||||
vertical = None
|
||||
print(rows, cols, table_name)
|
||||
#print(rows, cols, table_name)
|
||||
if rows > 2 and cols == 2:
|
||||
vertical = True
|
||||
elif cols == 1 and rows > 1:
|
||||
@@ -145,7 +145,7 @@ def parse(filename, output_dir, partnum, dstype):
|
||||
vertical = False
|
||||
else: # 1 column, <= 2 rows
|
||||
vertical = False
|
||||
print(vertical)
|
||||
#print(vertical)
|
||||
# missing name check
|
||||
for table_name_2 in table_list.keys():
|
||||
if dstype == "Alphawire" and table_name_2.find("\n") >= 0:
|
||||
@@ -182,11 +182,11 @@ def parse(filename, output_dir, partnum, dstype):
|
||||
|
||||
if prevtbl.cells[-1][0].lb[1] < 50 and thistbl.cells[0][0].lt[1] > 600:
|
||||
# wraparound
|
||||
print("WRAP")
|
||||
print("PREV TABLE", prevtbl.df)
|
||||
print("THIS TABLE", thistbl.df)
|
||||
print("PREV TABLE CORNER", prevtbl.cells[-1][0].lb[1])
|
||||
print("THIS TABLE CORNER", thistbl.cells[0][0].lt[1])
|
||||
#print("WRAP")
|
||||
#print("PREV TABLE", prevtbl.df)
|
||||
#print("THIS TABLE", thistbl.df)
|
||||
#print("PREV TABLE CORNER", prevtbl.cells[-1][0].lb[1])
|
||||
#print("THIS TABLE CORNER", thistbl.cells[0][0].lt[1])
|
||||
main_key = previous_table
|
||||
cont_key = table_name
|
||||
#print(vertical)
|
||||
@@ -200,21 +200,21 @@ def parse(filename, output_dir, partnum, dstype):
|
||||
del tables[table_name]
|
||||
|
||||
else:
|
||||
print(tables[cont_key].keys())
|
||||
#print(tables[cont_key].keys())
|
||||
for key in tables[cont_key].keys():
|
||||
print(main_key, key, cont_key, key)
|
||||
#print(main_key, key, cont_key, key)
|
||||
tables[main_key][key] = tables[cont_key][key]
|
||||
del tables[table_name]
|
||||
|
||||
elif thistbl.cells[0][0].lt[1] > 600:
|
||||
# name on previous page (grrrr)
|
||||
print("NAMEABOVE")
|
||||
print("PREV TABLE", prevtbl.df)
|
||||
print("THIS TABLE", thistbl.df)
|
||||
print("PREV TABLE CORNER", prevtbl.cells[-1][0].lb[1])
|
||||
print("THIS TABLE CORNER", thistbl.cells[0][0].lt[1])
|
||||
#print("NAMEABOVE")
|
||||
#print("PREV TABLE", prevtbl.df)
|
||||
#print("THIS TABLE", thistbl.df)
|
||||
#print("PREV TABLE CORNER", prevtbl.cells[-1][0].lb[1])
|
||||
#print("THIS TABLE CORNER", thistbl.cells[0][0].lt[1])
|
||||
name = extract_table_name(50, prevtbl.page,reader,dstype,table_name).strip("\n").strip()
|
||||
print("FOUND NAME:", name)
|
||||
#print("FOUND NAME:", name)
|
||||
torename[table_name] = name
|
||||
|
||||
|
||||
@@ -287,7 +287,7 @@ def parse(filename, output_dir, partnum, dstype):
|
||||
with open(output_dir + "/specs_" + output_table["partnum"] + ".json", 'w') as json_file:
|
||||
json.dump(output_table["fullspecs"], json_file)
|
||||
|
||||
print(json.dumps(output_table, indent=2))
|
||||
#print(json.dumps(output_table, indent=2))
|
||||
touch(output_dir + "/parsed") # mark as parsed
|
||||
return output_table
|
||||
|
||||
|
||||
Reference in New Issue
Block a user