Created
June 3, 2022 03:11
-
-
Save thehappycheese/ac62ae808ea74a61578738b580cdbb58 to your computer and use it in GitHub Desktop.
Load CSV files from Zip and Stack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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