Marthee commited on
Commit
4c14408
·
verified ·
1 Parent(s): c754a09

Update google_sheet_Legend.py

Browse files
Files changed (1) hide show
  1. google_sheet_Legend.py +16 -8
google_sheet_Legend.py CHANGED
@@ -578,6 +578,7 @@ def deletefromlegend(deletedrows, SimilarAreaDictionarycopy, section, areaPermAr
578
  myDict = eval(SimilarAreaDictionarycopy)
579
  SimilarAreaDictionarycopy = pd.DataFrame(myDict)
580
  strings = deletedrows['content']
 
581
  colors = deletedrows['color']
582
  indicies_toDelete=[]
583
  # print(colors)
@@ -601,18 +602,23 @@ def deletefromlegend(deletedrows, SimilarAreaDictionarycopy, section, areaPermAr
601
 
602
  # print('eee',existing_color,color)
603
  if is_color_within_tolerance(existing_color, color, tolerance):
604
- # print(f'Color {color} found close to {existing_color} at index {idx}')
605
  found = True
606
  # print('strings',strings[j])
607
- matchA = re.search(r"Area=(\d+\.\d+)", strings[j])
608
- matchP = re.search(r"Perimeter=(\d+\.\d+)", strings[j])
609
- matchL = re.search(r"Length=(\d+\.\d+)", strings[j])
 
 
 
610
 
611
  comment = SimilarAreaDictionarycopy.iloc[int(idx), SimilarAreaDictionarycopy.columns.get_loc('Comments')]
612
  occ = SimilarAreaDictionarycopy.iloc[int(idx), SimilarAreaDictionarycopy.columns.get_loc('Occurences')]
613
 
614
  # Only subtract area if the area value is found
615
- if matchA:
 
 
616
  # print(' SimilarAreaDictionaryArea', float(matchA.group(1)), SimilarAreaDictionarycopy.iloc[int(idx), SimilarAreaDictionarycopy.columns.get_loc('Total Area')])
617
  SimilarAreaDictionarycopy.iloc[int(idx), SimilarAreaDictionarycopy.columns.get_loc('Total Area')] =SimilarAreaDictionarycopy.iloc[int(idx), SimilarAreaDictionarycopy.columns.get_loc('Total Area')] - float(matchA.group(1))
618
  # Update area occurrences
@@ -625,8 +631,9 @@ def deletefromlegend(deletedrows, SimilarAreaDictionarycopy, section, areaPermAr
625
  perimeter_occurrences = SimilarAreaDictionarycopy.iloc[int(idx), SimilarAreaDictionarycopy.columns.get_loc('Occurences')]
626
 
627
  SimilarAreaDictionarycopy.iloc[int(idx), SimilarAreaDictionarycopy.columns.get_loc('Comments')] = f'Area occurrences: {area_occurrences}, Perimeter occurrences: {perimeter_occurrences}'
628
- if matchP:
629
-
 
630
  SimilarAreaDictionarycopy.iloc[int(idx), SimilarAreaDictionarycopy.columns.get_loc('Total Perimeter')] =SimilarAreaDictionarycopy.iloc[int(idx), SimilarAreaDictionarycopy.columns.get_loc('Total Perimeter')] - float(matchP.group(1))# Replace 'Area' with the actual column name
631
  if pd.notna(comment) and 'Perimeter' in str(comment):
632
  matches = re.findall(r'\b\d+\b', str(comment))
@@ -638,7 +645,8 @@ def deletefromlegend(deletedrows, SimilarAreaDictionarycopy, section, areaPermAr
638
  perimeter_occurrences = SimilarAreaDictionarycopy.iloc[int(idx), SimilarAreaDictionarycopy.columns.get_loc('Occurences')]-1
639
  # print(area_occurrences,perimeter_occurrences)
640
  SimilarAreaDictionarycopy.iloc[int(idx), SimilarAreaDictionarycopy.columns.get_loc('Comments')] = f'Area occurrences: {area_occurrences}, Perimeter occurrences: {perimeter_occurrences}'
641
-
 
642
 
643
 
644
 
 
578
  myDict = eval(SimilarAreaDictionarycopy)
579
  SimilarAreaDictionarycopy = pd.DataFrame(myDict)
580
  strings = deletedrows['content']
581
+ print('content',deletedrows)
582
  colors = deletedrows['color']
583
  indicies_toDelete=[]
584
  # print(colors)
 
602
 
603
  # print('eee',existing_color,color)
604
  if is_color_within_tolerance(existing_color, color, tolerance):
605
+ print(f'Color {color} found close to {existing_color} at index {idx}')
606
  found = True
607
  # print('strings',strings[j])
608
+ # matchA = re.search(r"Area=(\d+\.\d+)", strings[j])
609
+ # matchP = re.search(r"Perimeter=(\d+\.\d+)", strings[j])
610
+
611
+
612
+ # else:
613
+ # matchL = re.search(r"(\d+\.\d+)\s*m(?![a-zA-Z])", strings[j])
614
 
615
  comment = SimilarAreaDictionarycopy.iloc[int(idx), SimilarAreaDictionarycopy.columns.get_loc('Comments')]
616
  occ = SimilarAreaDictionarycopy.iloc[int(idx), SimilarAreaDictionarycopy.columns.get_loc('Occurences')]
617
 
618
  # Only subtract area if the area value is found
619
+ if "Area" in deletedrows['subject'][j]:
620
+ matchA = re.search(r"(\d+\.\d+)\s*sq\s*m",strings[j])
621
+ print('matchA')
622
  # print(' SimilarAreaDictionaryArea', float(matchA.group(1)), SimilarAreaDictionarycopy.iloc[int(idx), SimilarAreaDictionarycopy.columns.get_loc('Total Area')])
623
  SimilarAreaDictionarycopy.iloc[int(idx), SimilarAreaDictionarycopy.columns.get_loc('Total Area')] =SimilarAreaDictionarycopy.iloc[int(idx), SimilarAreaDictionarycopy.columns.get_loc('Total Area')] - float(matchA.group(1))
624
  # Update area occurrences
 
631
  perimeter_occurrences = SimilarAreaDictionarycopy.iloc[int(idx), SimilarAreaDictionarycopy.columns.get_loc('Occurences')]
632
 
633
  SimilarAreaDictionarycopy.iloc[int(idx), SimilarAreaDictionarycopy.columns.get_loc('Comments')] = f'Area occurrences: {area_occurrences}, Perimeter occurrences: {perimeter_occurrences}'
634
+ if "Perimeter" in deletedrows['subject'][j]:
635
+ matchP = re.search(r"(\d+\.\d+)\s*m(?![a-zA-Z])", strings[j])
636
+ print('matchP')
637
  SimilarAreaDictionarycopy.iloc[int(idx), SimilarAreaDictionarycopy.columns.get_loc('Total Perimeter')] =SimilarAreaDictionarycopy.iloc[int(idx), SimilarAreaDictionarycopy.columns.get_loc('Total Perimeter')] - float(matchP.group(1))# Replace 'Area' with the actual column name
638
  if pd.notna(comment) and 'Perimeter' in str(comment):
639
  matches = re.findall(r'\b\d+\b', str(comment))
 
645
  perimeter_occurrences = SimilarAreaDictionarycopy.iloc[int(idx), SimilarAreaDictionarycopy.columns.get_loc('Occurences')]-1
646
  # print(area_occurrences,perimeter_occurrences)
647
  SimilarAreaDictionarycopy.iloc[int(idx), SimilarAreaDictionarycopy.columns.get_loc('Comments')] = f'Area occurrences: {area_occurrences}, Perimeter occurrences: {perimeter_occurrences}'
648
+ else:
649
+ matchL = re.search(r"(\d+\.\d+)\s*m(?![a-zA-Z])", strings[j])
650
 
651
 
652