Created
November 19, 2020 09:48
-
-
Save ajomathew/434efea87652ff9a553585d56d9f2d4e to your computer and use it in GitHub Desktop.
Generate a excel sheet from csv files located in a from same folder
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 | |
import numpy as np | |
import os, fnmatch | |
listofcsvs = os.listdir(".") | |
pattern = "*.csv" | |
GNF = pd.ExcelWriter('Consolidated.xlsx') | |
for file in listofcsvs: | |
if fnmatch.fnmatch(file, pattern): | |
print(file) | |
df_csv = pd.read_csv(file) | |
df_csv.to_excel(GNF, sheet_name=file.split('.')[1], index=False) | |
GNF.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment