Last active
June 26, 2017 12:05
-
-
Save lexifdev/b62d7731ce5f1171043371c81f04461f 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 csv | |
from openpyxl import load_workbook | |
def cleanup(col): | |
if not col: | |
return '' | |
col = str(col) | |
col = col.replace('\n', '') | |
col = col.replace('\r', '') | |
return col | |
def convert(xlsx_filename, csv_filename): | |
csv_file = open(csv_filename, 'w+') | |
csv_writer = csv.writer(csv_file) | |
wb = load_workbook(xlsx_filename) | |
for row in wb.worksheets[1].values: | |
row = [cleanup(col) for col in row] | |
csv_writer.writerow(row) | |
for year in range(2011, 2017): | |
xlsx_filename = 'newstapa-jaesan-%s.xlsx' % year | |
csv_filename = 'newstapa-jaesan-%s-records.csv' % year | |
convert(xlsx_filename, csv_filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment