Skip to content

Instantly share code, notes, and snippets.

@alecbw
Created September 12, 2020 06:50
Show Gist options
  • Save alecbw/fa147f2e19c43063fe9775ca20046cd8 to your computer and use it in GitHub Desktop.
Save alecbw/fa147f2e19c43063fe9775ca20046cd8 to your computer and use it in GitHub Desktop.
In one command, open a Python shell, get every CSV and XLSX in the local directory, and print its name, row/col count, and column names
python3
import pandas as pd; import os; files = [f for f in os.listdir('.') if (os.path.isfile(f) and os.path.getsize(f) != 0 and any(x for x in [".csv", ".xlsx"] if x in f))]; print(files); df_tuples = [(f, pd.read_csv(f)) for f in files]; [print(df_tup[0], df_tup[1].shape, df_tup[1].columns, "\n") for df_tup in df_tuples]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment