Navigation Menu

Skip to content

Commit

Permalink
add --sheet option support for XLS
Browse files Browse the repository at this point in the history
  • Loading branch information
James McKinney committed Sep 5, 2012
1 parent 11e9911 commit fae2725
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 4 additions & 1 deletion csvkit/convert/xls.py
Expand Up @@ -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()

Expand Down
3 changes: 1 addition & 2 deletions csvkit/convert/xlsx.py
Expand Up @@ -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()

Expand Down

0 comments on commit fae2725

Please sign in to comment.