Last active
July 16, 2019 21:02
-
-
Save allanbatista/9743aef18c4b059fb2d344b7fe1d732e to your computer and use it in GitHub Desktop.
Converte arquivos XLSX para CSV em um diretório
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 xlrd | |
import csv | |
import glob, os | |
for file in glob.glob("*.xlsx"): | |
print("{} start".format(file)) | |
wb = xlrd.open_workbook(file) | |
sh = wb.sheet_by_name('Plan1') | |
with open("{}.csv".format(file.split(".")[0]), 'w+') as f: | |
wr = csv.writer(f, quoting=csv.QUOTE_ALL) | |
count = 0 | |
for rownum in range(sh.nrows): | |
wr.writerow(sh.row_values(rownum)) | |
count += 1 | |
sys.stdout.write("%s %s%%\r" % (file, count)) | |
sys.stdout.flush() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment