Skip to content

Instantly share code, notes, and snippets.

@jimkutter
Created January 29, 2019 14:11
Show Gist options
  • Save jimkutter/b2f2c2cf45444bca91043465b10d2388 to your computer and use it in GitHub Desktop.
Save jimkutter/b2f2c2cf45444bca91043465b10d2388 to your computer and use it in GitHub Desktop.
Uses python 3, may work with 2.
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