leadingbridge commited on
Commit
ba3e209
·
verified ·
1 Parent(s): 8228e94

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -88,7 +88,6 @@ def process_file(file):
88
  if "Total Weight" in df.columns:
89
  def convert_weight(x):
90
  try:
91
- # Only convert if value is not blank
92
  if pd.isna(x) or x == "":
93
  return ""
94
  return float(x) / 1000
@@ -103,6 +102,9 @@ def process_file(file):
103
  output_df.loc[mask, "Description of Goods"] = "Eyes Beauty Color Cosmetics"
104
  output_df.loc[mask, "Service"] = "7"
105
 
 
 
 
106
  # Generate the output file name using the current Hong Kong date.
107
  hk_timezone = pytz.timezone("Asia/Hong_Kong")
108
  current_date_hk = datetime.now(hk_timezone).strftime("%y%m%d")
@@ -124,11 +126,14 @@ with gr.Blocks(title="Shipping - UPS") as demo:
124
 
125
  process_button.click(fn=process_file, inputs=[file_input], outputs=[output_data, output_file_component])
126
 
127
- # Add new clickable hyperlink at the bottom.
128
  gr.HTML(
129
  """
130
  <div style="text-align: center; font-size: 16px; margin-top: 20px;">
131
- <a href="https://huggingface.co/spaces/leadingbridge/shipping-UPS">UPS</a>
 
 
 
132
  </div>
133
  """
134
  )
 
88
  if "Total Weight" in df.columns:
89
  def convert_weight(x):
90
  try:
 
91
  if pd.isna(x) or x == "":
92
  return ""
93
  return float(x) / 1000
 
102
  output_df.loc[mask, "Description of Goods"] = "Eyes Beauty Color Cosmetics"
103
  output_df.loc[mask, "Service"] = "7"
104
 
105
+ # Delete duplicate rows based on "Contact Name", keeping the first occurrence.
106
+ output_df = output_df.drop_duplicates(subset=["Contact Name"], keep="first")
107
+
108
  # Generate the output file name using the current Hong Kong date.
109
  hk_timezone = pytz.timezone("Asia/Hong_Kong")
110
  current_date_hk = datetime.now(hk_timezone).strftime("%y%m%d")
 
126
 
127
  process_button.click(fn=process_file, inputs=[file_input], outputs=[output_data, output_file_component])
128
 
129
+ # Updated hyperlink block with UPS and additional links.
130
  gr.HTML(
131
  """
132
  <div style="text-align: center; font-size: 16px; margin-top: 20px;">
133
+ <a href="https://huggingface.co/spaces/leadingbridge/shipping-UPS">UPS</a> |
134
+ <a href="https://huggingface.co/spaces/leadingbridge/shipping-ec-ship">EC-Ship</a> |
135
+ <a href="https://huggingface.co/spaces/leadingbridge/shipping-dhl-e-commerce">DHL Ecommerce</a> |
136
+ <a href="https://huggingface.co/spaces/leadingbridge/shipping-fedex">Fedex</a>
137
  </div>
138
  """
139
  )