Skip to content

Instantly share code, notes, and snippets.

@thehappycheese
Created June 3, 2022 03:11
Show Gist options
  • Save thehappycheese/ac62ae808ea74a61578738b580cdbb58 to your computer and use it in GitHub Desktop.
Save thehappycheese/ac62ae808ea74a61578738b580cdbb58 to your computer and use it in GitHub Desktop.
Load CSV files from Zip and Stack
import pandas
from zipfile import ZipFile
zip_file_path = "some_zip.zip"
# some_zip.zip/
# ├─ part1.csv
# ├─ part2.csv
# ├─ part3.csv
zip_file = ZipFile(zip_file_path)
extracted_data = pd.concat([
pandas.read_csv(
zip_file.open(
item
)
)
for item in zip_file.namelist()
if item.endswith(".csv")
])
extracted_data = extracted_data.reset_index()
extracted_data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment