leadingbridge commited on
Commit
6dea108
·
verified ·
1 Parent(s): 3ae5fff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -61,13 +61,16 @@ def process_file(file):
61
  if "Shipping Province" in df.columns:
62
  output_df["Province/State"] = df["Shipping Province"]
63
 
64
- # 6. ZipCode (pad 4-digit US zips with a leading zero)
65
  if "Shipping ZIP" in df.columns:
66
  zip_raw = df["Shipping ZIP"].astype(str).str.strip()
67
  mask_us = output_df["CountryCode"] == "US"
68
  mask_4 = zip_raw.str.len() == 4
69
- zip_fixed = zip_raw.where(~(mask_us & mask_4), "0" + zip_raw)
70
- output_df["ZipCode"] = zip_fixed
 
 
 
71
 
72
  # 7. CountryCode
73
  if "Shipping Country Code" in df.columns:
 
61
  if "Shipping Province" in df.columns:
62
  output_df["Province/State"] = df["Shipping Province"]
63
 
64
+ # 6. ZipCode (pad 4-digit US zips with a leading zero + apostrophe for text)
65
  if "Shipping ZIP" in df.columns:
66
  zip_raw = df["Shipping ZIP"].astype(str).str.strip()
67
  mask_us = output_df["CountryCode"] == "US"
68
  mask_4 = zip_raw.str.len() == 4
69
+ # pad to 5 digits
70
+ zip_padded = zip_raw.where(~(mask_us & mask_4), "0" + zip_raw)
71
+ # prefix apostrophe so Excel treats it as text and preserves leading zero
72
+ zip_final = zip_padded.where(~(mask_us & mask_4), "'" + zip_padded)
73
+ output_df["ZipCode"] = zip_final
74
 
75
  # 7. CountryCode
76
  if "Shipping Country Code" in df.columns: