Created
February 25, 2021 10:58
-
-
Save cybertramp/83627922321d339c9ea10212936f2f67 to your computer and use it in GitHub Desktop.
csv to xlsx convert code
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
#!/usr/bin/python3 | |
import pandas as pd | |
import numpy as np | |
import glob | |
import sys | |
from openpyxl import Workbook | |
import os | |
import csv | |
path = "./" | |
file_list = os.listdir(path) | |
file_list_csv = [file for file in file_list if file.endswith(".csv")] | |
file_list_csv.sort() | |
wb = Workbook() | |
ws = wb.active | |
for i,d in enumerate(file_list_csv): | |
print(i, d) | |
with open(d, 'r', encoding='utf8') as f: | |
for row in csv.reader(f): | |
ws.append(row) | |
wb.save('res.xlsx') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment