Skip to content

Commit

Permalink
Add docstrings to excel.py
Browse files Browse the repository at this point in the history
  • Loading branch information
kinverarity1 committed Oct 27, 2017
1 parent fe87fac commit fe35ce3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/source/lasio.rst
Expand Up @@ -54,7 +54,7 @@ lasio\.excel module

.. automodule:: lasio.excel
:members:
:undoc-members:
:undoc-members: main get_parser main_bulk get_bulk_parser
:show-inheritance:
:member-order: bysource

Expand Down
26 changes: 23 additions & 3 deletions lasio/excel.py
Expand Up @@ -10,24 +10,38 @@

class ExcelConverter(object):

'''
'''Provide ability to export LAS data into an Excel spreadsheet.
Arguments:
las: LASFile object
las (:class:`lasio.las.LASFile` object)
'''

def __init__(self, las):
self.set_las(las)

def set_las(self, las):
'''Set LASFile object.
Arguments:
las (:class:`lasio.las.LASFile` object)
'''
self.las = las
self.generate_workbook()
return self

def generate_workbook(self):
'''Generate the Excel workbook object.
Two sheets are created:
* Header: contains all the header sections and metadata
* Curves: contains the data
'''
wb = openpyxl.Workbook()
header = wb['Sheet']
# header = wb.create_sheet()
header.title = 'Header'
curves = wb.create_sheet()
curves.title = 'Curves'
Expand Down Expand Up @@ -71,6 +85,12 @@ def write_cell(sh, i, j, value):
return self

def write(self, xlsxfn):
'''Write the Excel workbook to an ``.xlsx`` file.
Arguments:
xlsxfn (str): filename (will be overwritten without warning)
'''
assert xlsxfn.lower().endswith('.xlsx')

self.workbook.save(xlsxfn)
Expand Down

0 comments on commit fe35ce3

Please sign in to comment.