Skip to content

Instantly share code, notes, and snippets.

@cybertramp
Created February 25, 2021 10:58
Show Gist options
  • Save cybertramp/83627922321d339c9ea10212936f2f67 to your computer and use it in GitHub Desktop.
Save cybertramp/83627922321d339c9ea10212936f2f67 to your computer and use it in GitHub Desktop.
csv to xlsx convert code
#!/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