Last active
October 3, 2018 00:26
-
-
Save alfonsokim/c1fda241b347be5cb7f94ea364223344 to your computer and use it in GitHub Desktop.
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 os | |
import pandas | |
import openpyxl | |
writer = pandas.ExcelWriter('ruta al excel de salida', engine='openpyxl') | |
current_row = 0 | |
all_excel_dir = 'ruta al directorio de exceles' | |
for fidx, one_file in enumerate(os.listdir(all_excel_dir)): | |
if one_file.split('.')[-1] == 'xlsx': | |
path = os.path.join(all_excel_dir, one_file) | |
df = pandas.read_excel(path, index=False) | |
dft = pandas.DataFrame(df.T, columns=df.index.values) | |
dft.to_excel(writer, startrow=current_row, index=False, header=fidx == 0) | |
current_row += dft.shape[0] + (1 if fidx == 0 else 0) | |
writer.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment