Created
May 30, 2018 07:11
-
-
Save netsharec/9b8e9719704772f1c587a4ab64a99ebe to your computer and use it in GitHub Desktop.
csv2excel
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/env python | |
import os | |
import glob | |
import csv | |
from xlsxwriter.workbook import Workbook | |
for csvfile in glob.glob(os.path.join('.', '*.csv')): | |
workbook = Workbook(csvfile + '.xlsx') | |
worksheet = workbook.add_worksheet() | |
with open(csvfile, 'rb') as f: | |
reader = csv.reader(f) | |
for r, row in enumerate(reader): | |
for c, col in enumerate(row): | |
worksheet.write(r, c, col) | |
workbook.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment