Skip to content

Instantly share code, notes, and snippets.

@vikjam
Created July 8, 2015 02:30
Show Gist options
  • Save vikjam/e2b1761c105dfcb64d80 to your computer and use it in GitHub Desktop.
Save vikjam/e2b1761c105dfcb64d80 to your computer and use it in GitHub Desktop.
import xlrd
import os
import gzip
workbook = xlrd.open_workbook("example.xlsx")
worksheet = workbook.sheet_by_index(0)
for row_num in range(0, worksheet.nrows):
row_values = [v.value for v in worksheet.row(row_num) if v.value]
if not any(row_values):
continue
if row_values[0] in ['FileName', 'File Name']:
continue
filepath = "~/" + '/'.join(reversed(row_values))
fullpath = os.path.expanduser(filepath)
with gzip.open(fullpath, 'r') as f:
for line in f:
col_nums = len(str(line).split(','))
print(col_nums)
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment