Spaces:
Build error
Build error
Update tariff_scraper.py
Browse files- tariff_scraper.py +5 -2
tariff_scraper.py
CHANGED
|
@@ -43,10 +43,13 @@ def scrape_multiple_sections_to_csv(url, output_file="pesco_tariff_data.csv"):
|
|
| 43 |
data.append(cols)
|
| 44 |
|
| 45 |
# Create a dataframe for the current table
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
# Ensure column names are unique
|
| 49 |
-
df.columns = pd.
|
| 50 |
|
| 51 |
# Add a section identifier
|
| 52 |
df["Section"] = f"Section {i}"
|
|
|
|
| 43 |
data.append(cols)
|
| 44 |
|
| 45 |
# Create a dataframe for the current table
|
| 46 |
+
if len(data) > 1:
|
| 47 |
+
df = pd.DataFrame(data[1:], columns=data[0])
|
| 48 |
+
else:
|
| 49 |
+
df = pd.DataFrame(data)
|
| 50 |
|
| 51 |
# Ensure column names are unique
|
| 52 |
+
df.columns = pd.io.parsers.ParserBase({'names': df.columns})._maybe_dedup_names()
|
| 53 |
|
| 54 |
# Add a section identifier
|
| 55 |
df["Section"] = f"Section {i}"
|