Skip to content

Instantly share code, notes, and snippets.

@aurorapar
Created November 4, 2016 20:40
Show Gist options
  • Save aurorapar/691e36c801d9fb849eb55b59800aa355 to your computer and use it in GitHub Desktop.
Save aurorapar/691e36c801d9fb849eb55b59800aa355 to your computer and use it in GitHub Desktop.
import xlrd
import os
path = "C:\\users\\nx7233pl\\Documents\\school\\STAT210\\"
output = path + "bike-stops.txt"
book = xlrd.open_workbook(path + "citibike-concat-stops.xlsx")
print(book.sheet_names()) # []
sheet = book.sheet_by_index(0) # Index out of bounds
firstCell = (1,16)
lastCell = (1048575,16)
stops = []
for x in range(firstCell[0], lastCell[0] + 1):
stop = int(sheet.cell(x,16))
if stop not in stops:
stops[stop] = 1
else:
stops[stop] += 1
with open(output, 'w') as file:
for stop in stops:
file.write('Stop %s %s'%(str(stop) + ':', stops[stop]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment