Add No. column to output

#1
by linh-hk - opened
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -1116,15 +1116,16 @@ with gr.Blocks() as interface:
1116
  <table style='width:100%; border-collapse: collapse; table-layout: auto; font-size: 14px; color: inherit; background-color: inherit;'>
1117
  """
1118
 
1119
- headers = ["Sample ID", "Predicted Country", "Country Explanation", "Predicted Sample Type", "Sample Type Explanation", "Sources", "Time cost"]
1120
  html += "".join(
1121
  f"<th style='padding: 10px; border: 1px solid #555; text-align: left; white-space: nowrap;'>{h}</th>"
1122
  for h in headers
1123
  )
1124
  html += "</tr></thead><tbody>"
1125
 
1126
- for row in rows:
1127
  html += "<tr>"
 
1128
  for i, col in enumerate(row):
1129
  header = headers[i]
1130
  style = "padding: 10px; border: 1px solid #555; vertical-align: top;"
 
1116
  <table style='width:100%; border-collapse: collapse; table-layout: auto; font-size: 14px; color: inherit; background-color: inherit;'>
1117
  """
1118
 
1119
+ headers = ["No.", "Sample ID", "Predicted Country", "Country Explanation", "Predicted Sample Type", "Sample Type Explanation", "Sources", "Time cost"]
1120
  html += "".join(
1121
  f"<th style='padding: 10px; border: 1px solid #555; text-align: left; white-space: nowrap;'>{h}</th>"
1122
  for h in headers
1123
  )
1124
  html += "</tr></thead><tbody>"
1125
 
1126
+ for idx, row in enumerate(rows, 1): # start numbering from 1
1127
  html += "<tr>"
1128
+ html += f"<td style='padding: 10px; border: 1px solid #555;'>{idx}</td>" # "No." column
1129
  for i, col in enumerate(row):
1130
  header = headers[i]
1131
  style = "padding: 10px; border: 1px solid #555; vertical-align: top;"