Skip to content

Instantly share code, notes, and snippets.

@alexstorer
Created August 29, 2013 03:47
Show Gist options
  • Save alexstorer/6374049 to your computer and use it in GitHub Desktop.
Save alexstorer/6374049 to your computer and use it in GitHub Desktop.
#!/usr/env python
from subprocess import call
import datetime
import os
import xlrd
import csv
def csv_from_excel():
wb = xlrd.open_workbook('temp.xls')
sh = wb.sheet_by_index(0)
your_csv_file = open('catalog-extra-info.csv', 'wb')
wr = csv.writer(your_csv_file, quoting=csv.QUOTE_ALL)
for rownum in xrange(sh.nrows):
wr.writerow(sh.row_values(rownum))
your_csv_file.close()
#curl https://legacy.unfi.com/uploadedFiles/UNFI_ER/09_FullListingBYCSeptember.xls -o temp.xls
today = datetime.date.today()
monthnum = today.strftime("%m")
monthwords = today.strftime("%B")
yearnum = today.strftime("%Y")
filename = "https://legacy.unfi.com/uploadedFiles/UNFI_ER/"+monthnum+"_FullListingBYC"+monthwords+yearnum+".xls"
call(["curl", filename,"-o","temp.xls"])
if os.path.getsize("temp.xls") > 10000:
csv_from_excel()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment