Skip to content

Instantly share code, notes, and snippets.

@xyb
Created March 23, 2023 08:09
Show Gist options
  • Save xyb/1d7c6cf449039332b4c4ceb787d33ef4 to your computer and use it in GitHub Desktop.
Save xyb/1d7c6cf449039332b4c4ceb787d33ef4 to your computer and use it in GitHub Desktop.
convert excel to csv
import openpyxl
import csv
import sys
input = sys.argv[1]
output = sys.argv[2]
print(f'{input} ==> {output}')
wb = load_workbook(input)
sh = wb.active
with open(output, 'w') as f:
c = csv.writer(f)
for r in sh.rows:
c.writerow([cell.value for cell in r])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment