Marthee commited on
Commit
bd20ee3
·
verified ·
1 Parent(s): 6baaa4b

Update Doors_Schedule.py

Browse files
Files changed (1) hide show
  1. Doors_Schedule.py +24 -6
Doors_Schedule.py CHANGED
@@ -495,14 +495,15 @@ def get_selected_columns_all(dfs, user_patterns):
495
  #print(len(clm_idx))
496
  #details in another table
497
  print(column_index_list)
498
- if len(dfs[i]) <10:
499
- selected_columns_new = details_in_another_table(clmn_name, column_index_list, dfs[i], dfs)
500
  #break
501
  #other_matches = details_in_another_table_mod(clmn_name, clmn_idx, dfs[i], dfs)
502
  #details in the same table
503
- if len(dfs[i]) >10:
504
- selected_columns_new = generate_current_table_without_cropping(column_index_list,dfs[i])
505
- selected_columns_new.columns = clmn_name # must match number of columns
 
 
506
 
507
  #break
508
 
@@ -1832,7 +1833,11 @@ def mainRun(schedule, plan, searcharray, sch_csv_pdf):
1832
  drop_empty_locations=True,
1833
  explode_locations=True)
1834
  df_points.columns = df_points.columns.str.strip().str.replace(r"\s+", "_", regex=True)
1835
-
 
 
 
 
1836
  # handling no door type in the new dictionary logic
1837
  if 'color' not in df_points:
1838
  df_points['color'] = (0, 0, 255)
@@ -1871,6 +1876,8 @@ def mainRun(schedule, plan, searcharray, sch_csv_pdf):
1871
  #widht_count, height_count = generate_separate_dimensions(widths)
1872
  #bax = create_bb_bax_secondary(new_data3, widht_count, height_count, secondary_tobeprinted, CountStyles, user_input, page_number, page)
1873
  #bax_annotations_all_inputs.append(bax)
 
 
1874
  bax, customDta = create_bb_bax_new(df_points, CountStyles, page_number, page)
1875
  bax_annotations_all_inputs.append(bax)
1876
 
@@ -1915,6 +1922,7 @@ def mainRun(schedule, plan, searcharray, sch_csv_pdf):
1915
  list1=pd.DataFrame(columns=['content', 'id', 'subject','color'])
1916
  print(f"number of pges of doc2 is {len_doc2} and its type is {type(doc2)}")
1917
  for page in doc2:
 
1918
  # page=doc2[0]
1919
  pix = page.get_pixmap() # render page to an image
1920
  pl=Image.frombytes('RGB', [pix.width,pix.height],pix.samples)
@@ -1922,11 +1930,16 @@ def mainRun(schedule, plan, searcharray, sch_csv_pdf):
1922
  annotatedimg = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
1923
  annotatedimgs.append(annotatedimg)
1924
  # Iterate through annotations on the page
 
 
 
1925
  for annot in page.annots():
1926
  # Get the color of the annotation
 
1927
  annot_color = annot.colors
1928
  if annot_color is not None:
1929
  # annot_color is a dictionary with 'stroke' and 'fill' keys
 
1930
  stroke_color = annot_color.get('stroke') # Border color
1931
  fill_color = annot_color.get('fill') # Fill color
1932
  if fill_color:
@@ -1935,6 +1948,11 @@ def mainRun(schedule, plan, searcharray, sch_csv_pdf):
1935
  if stroke_color:
1936
  v='stroke'
1937
  x,y,z=int(annot_color.get(v)[0]*255),int(annot_color.get(v)[1]*255),int(annot_color.get(v)[2]*255)
 
 
 
1938
  list1.loc[len(list1)] =[annot.info['content'],annot.info['id'],annot.info['subject'],[x,y,z]]
 
 
1939
  return annotatedimgs, doc2 , list1, repeated_labels , not_found, pretty_xml, column_xml
1940
 
 
495
  #print(len(clm_idx))
496
  #details in another table
497
  print(column_index_list)
498
+ #if len(dfs[i]) <10:
 
499
  #break
500
  #other_matches = details_in_another_table_mod(clmn_name, clmn_idx, dfs[i], dfs)
501
  #details in the same table
502
+ #if len(dfs[i]) >10:
503
+ selected_columns_new = details_in_another_table(clmn_name, column_index_list, dfs[i], dfs)
504
+ selected_columns_new2 = generate_current_table_without_cropping(column_index_list,dfs[i])
505
+ selected_columns_new = pd.concat([selected_columns_new, selected_columns_new2], ignore_index=True)
506
+ selected_columns_new.columns = clmn_name # must match number of columns
507
 
508
  #break
509
 
 
1833
  drop_empty_locations=True,
1834
  explode_locations=True)
1835
  df_points.columns = df_points.columns.str.strip().str.replace(r"\s+", "_", regex=True)
1836
+ print(f"col_dict: {col_dict}")
1837
+ print(f"selected_columns_combined: {selected_columns_combined}")
1838
+ print(f"df: {df_points}")
1839
+ if df_points.empty:
1840
+ continue
1841
  # handling no door type in the new dictionary logic
1842
  if 'color' not in df_points:
1843
  df_points['color'] = (0, 0, 255)
 
1876
  #widht_count, height_count = generate_separate_dimensions(widths)
1877
  #bax = create_bb_bax_secondary(new_data3, widht_count, height_count, secondary_tobeprinted, CountStyles, user_input, page_number, page)
1878
  #bax_annotations_all_inputs.append(bax)
1879
+ print(f"colors: {df_points['color']}")
1880
+ print(f"df: {df_points}")
1881
  bax, customDta = create_bb_bax_new(df_points, CountStyles, page_number, page)
1882
  bax_annotations_all_inputs.append(bax)
1883
 
 
1922
  list1=pd.DataFrame(columns=['content', 'id', 'subject','color'])
1923
  print(f"number of pges of doc2 is {len_doc2} and its type is {type(doc2)}")
1924
  for page in doc2:
1925
+ print("now inside page in doc2")
1926
  # page=doc2[0]
1927
  pix = page.get_pixmap() # render page to an image
1928
  pl=Image.frombytes('RGB', [pix.width,pix.height],pix.samples)
 
1930
  annotatedimg = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
1931
  annotatedimgs.append(annotatedimg)
1932
  # Iterate through annotations on the page
1933
+ annotations_page = page.annots()
1934
+ print(f"annotations: {annotations_page}")
1935
+ '''
1936
  for annot in page.annots():
1937
  # Get the color of the annotation
1938
+ print("ann: {annot}")
1939
  annot_color = annot.colors
1940
  if annot_color is not None:
1941
  # annot_color is a dictionary with 'stroke' and 'fill' keys
1942
+ print(annot_color)
1943
  stroke_color = annot_color.get('stroke') # Border color
1944
  fill_color = annot_color.get('fill') # Fill color
1945
  if fill_color:
 
1948
  if stroke_color:
1949
  v='stroke'
1950
  x,y,z=int(annot_color.get(v)[0]*255),int(annot_color.get(v)[1]*255),int(annot_color.get(v)[2]*255)
1951
+ print(f"x: {x}")
1952
+ print(f"y: {y}")
1953
+ print(f"z: {z}")
1954
  list1.loc[len(list1)] =[annot.info['content'],annot.info['id'],annot.info['subject'],[x,y,z]]
1955
+ print(f"list1 : {list1}")
1956
+ '''
1957
  return annotatedimgs, doc2 , list1, repeated_labels , not_found, pretty_xml, column_xml
1958