Last active
January 29, 2019 14:11
-
-
Save jimkutter/f139b1ec95feb3fc0e48147e131f5d4b to your computer and use it in GitHub Desktop.
Uses python 3, may work with 2. Install xlrd, and tqdm using pip. Then pass xls(x) filename as first argument.
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 sys | |
from tqdm import tqdm | |
filename = sys.argv[1] | |
book = xlrd.open_workbook(filename) | |
sheet = book.sheet_by_index(0) | |
header = sheet.row(0) | |
with open(filename + ".txt", "w") as outfile: | |
for rx in tqdm(range(sheet.nrows)): | |
first = True | |
for cell in sheet.row(rx): | |
if first: | |
first = False | |
else: | |
outfile.write("|") | |
cell_value = str(cell.value).replace("\n", "") | |
outfile.write(cell_value) | |
outfile.write("\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment