Last active
June 23, 2020 02:42
-
-
Save saburbutt/50a545d2529a41361ac7f18e3ddcf6eb to your computer and use it in GitHub Desktop.
Reading multiple csv files and storing the data in the pandas dataframe
This file contains 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 as pd | |
from pathlib import Path | |
from glob import glob | |
allfiles = sorted(glob('Files/yob*.csv')) | |
print(allfiles) | |
home = str(Path.home()) | |
#The * in the path is basically the variable which changes in every file | |
#Read the full data and concatenate all the csv files | |
full_data = pd.concat((pd.read_csv(file) for file in allfiles), ignore_index = True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment