KutisBayag commited on
Commit
43e76e0
·
verified ·
1 Parent(s): 0a9ef90

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -5
app.py CHANGED
@@ -62,21 +62,38 @@ def process_sheet(sheet_url):
62
  name = row.get("Full Name", "")
63
  job_id = row.get("job_id", "")
64
 
65
- # TM column (R)
66
  tm = process_tags(row.get("Combined", ""))
67
 
68
  # Auditor: gather all AF–AW columns
69
  auditor_tags = []
70
  for col in df.columns:
71
- if col.startswith("A"): # AF, AG, AH, ...
72
  auditor_tags.append(str(row[col]))
73
  auditor = process_tags(", ".join(auditor_tags))
74
 
75
- # Format final text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  text = f"""{name}
77
  job id: {job_id}
78
  TM: {tm}
79
- Auditor: {auditor}"""
 
80
  outputs.append(text)
81
 
82
  return "\n\n---\n\n".join(outputs)
@@ -85,7 +102,7 @@ Auditor: {auditor}"""
85
  demo = gr.Interface(
86
  fn=process_sheet,
87
  inputs=gr.Textbox(label="Google Sheets Link", placeholder="Paste Google Sheets link here"),
88
- outputs=gr.Textbox(label="Formatted Output", lines=20),
89
  title="Google Sheets Formatter",
90
  description="Paste your Google Sheets link (make sure it's shared as 'Anyone with the link can view')."
91
  )
 
62
  name = row.get("Full Name", "")
63
  job_id = row.get("job_id", "")
64
 
65
+ # TM (from R)
66
  tm = process_tags(row.get("Combined", ""))
67
 
68
  # Auditor: gather all AF–AW columns
69
  auditor_tags = []
70
  for col in df.columns:
71
+ if col.startswith("A"): # AF, AG, AH...
72
  auditor_tags.append(str(row[col]))
73
  auditor = process_tags(", ".join(auditor_tags))
74
 
75
+ # Rule: if both TM and Auditor are blank → NT
76
+ if not tm.strip():
77
+ tm = "NT"
78
+ if not auditor.strip():
79
+ auditor = "NT"
80
+
81
+ # Column CC = rationale (fixed index approach)
82
+ # CC = 81st column (A=0, B=1, ..., CC=80)
83
+ rationale = ""
84
+ try:
85
+ rationale = row.iloc[80] # 0-based index for CC
86
+ except Exception:
87
+ rationale = ""
88
+
89
+ rationale_text = f"\n\nRationale: {rationale}" if pd.notna(rationale) and str(rationale).strip() else ""
90
+
91
+ # Final formatted text
92
  text = f"""{name}
93
  job id: {job_id}
94
  TM: {tm}
95
+ Auditor: {auditor}{rationale_text}"""
96
+
97
  outputs.append(text)
98
 
99
  return "\n\n---\n\n".join(outputs)
 
102
  demo = gr.Interface(
103
  fn=process_sheet,
104
  inputs=gr.Textbox(label="Google Sheets Link", placeholder="Paste Google Sheets link here"),
105
+ outputs=gr.Textbox(label="Formatted Output", lines=25),
106
  title="Google Sheets Formatter",
107
  description="Paste your Google Sheets link (make sure it's shared as 'Anyone with the link can view')."
108
  )