nouamanetazi HF staff commited on
Commit
86f908d
1 Parent(s): 7e32c39
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -93,28 +93,33 @@ def parse_latlng_from_link(url):
93
  return None
94
 
95
  def parse_gg_sheet_interventions(url):
96
- df = pd.read_csv(url)
 
 
97
  return df.assign(latlng=df.iloc[:, 3].apply(parse_latlng_from_link))
98
 
99
  def parse_gg_sheet(url):
100
  url = url.replace("edit#gid=", "export?format=csv&gid=")
101
- df = pd.read_csv(url)
 
102
 
103
  # parse latlng (column 4) to [lat, lng]
104
  def parse_latlng(latlng):
105
  try:
106
  lat, lng = latlng.split(",")
107
  return [float(lat), float(lng)]
108
- except Exception:
109
- return parse_latlng_from_link(latlng)
110
-
111
- return df.assign(latlng=df.iloc[:, 4].apply(parse_latlng))
 
 
112
 
113
  df = parse_gg_sheet(
114
  "https://docs.google.com/spreadsheets/d/1gYoBBiBo1L18IVakHkf3t1fOGvHWb23loadyFZUeHJs/edit#gid=966953708"
115
  )
116
  interventions_df = parse_gg_sheet_interventions(
117
- "https://docs.google.com/spreadsheets/d/1eXOTqunOWWP8FRdENPs4cU9ulISm4XZWYJJNR1-SrwY/gviz/tq?tqx=out:csv"
118
  )
119
 
120
  # select requests
 
93
  return None
94
 
95
  def parse_gg_sheet_interventions(url):
96
+ url = url.replace("edit#gid=", "export?format=csv&gid=")
97
+ print(url)
98
+ df = pd.read_csv(url, on_bad_lines='skip')
99
  return df.assign(latlng=df.iloc[:, 3].apply(parse_latlng_from_link))
100
 
101
  def parse_gg_sheet(url):
102
  url = url.replace("edit#gid=", "export?format=csv&gid=")
103
+ print(url)
104
+ df = pd.read_csv(url, on_bad_lines='warn')
105
 
106
  # parse latlng (column 4) to [lat, lng]
107
  def parse_latlng(latlng):
108
  try:
109
  lat, lng = latlng.split(",")
110
  return [float(lat), float(lng)]
111
+ except Exception as e:
112
+ print(f"Error parsing latlng: {e}")
113
+ return None
114
+ if df.shape[1] > 4:
115
+ df = df.assign(latlng=df.iloc[:, 4].apply(parse_latlng))
116
+ return df
117
 
118
  df = parse_gg_sheet(
119
  "https://docs.google.com/spreadsheets/d/1gYoBBiBo1L18IVakHkf3t1fOGvHWb23loadyFZUeHJs/edit#gid=966953708"
120
  )
121
  interventions_df = parse_gg_sheet_interventions(
122
+ "https://docs.google.com/spreadsheets/d/1eXOTqunOWWP8FRdENPs4cU9ulISm4XZWYJJNR1-SrwY/edit#gid=2089222765"
123
  )
124
 
125
  # select requests