Permalink
Browse files

add --sheet option support for XLS

  • Loading branch information...
1 parent 11e9911 commit fae2725366903e22fbca0e6c4a0c42d2c61514b8 @jpmckinney jpmckinney committed Sep 5, 2012
Showing with 5 additions and 3 deletions.
  1. +4 −1 csvkit/convert/xls.py
  2. +1 −2 csvkit/convert/xlsx.py
@@ -125,7 +125,10 @@ def xls2csv(f, **kwargs):
Convert an Excel .xls file to csv.
"""
book = xlrd.open_workbook(file_contents=f.read())
- sheet = book.sheet_by_index(0)
+ if 'sheet' in kwargs:
+ sheet = book.sheet_by_name(kwargs['sheet'])
+ else:
+ sheet = book.sheet_by_index(0)
tab = table.Table()
@@ -37,8 +37,7 @@ def xlsx2csv(f, output=None, **kwargs):
book = load_workbook(f, use_iterators=True)
if 'sheet' in kwargs:
- sheetn = kwargs['sheet']
- sheet = book.get_sheet_by_name(sheetn)
+ sheet = book.get_sheet_by_name(kwargs['sheet'])
else:
sheet = book.get_active_sheet()

0 comments on commit fae2725

Please sign in to comment.