Skip to content

Commit

Permalink
fixes #159
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed May 29, 2019
1 parent c3a7ddc commit 1a9a39a
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions apstools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
~EmailNotifications
~ExcelDatabaseFileBase
~ExcelDatabaseFileGeneric
~ExcelReadError
~json_export
~json_import
~ipython_profile_name
Expand Down Expand Up @@ -45,6 +46,7 @@
import smtplib
import subprocess
import time
import xlrd
import zipfile

from .plans import run_in_thread
Expand All @@ -55,6 +57,9 @@
MAX_EPICS_STRINGOUT_LENGTH = 40


class ExcelReadError(xlrd.XLRDError): ...


def cleanupText(text):
"""
convert text so it can be used as a dictionary key
Expand Down Expand Up @@ -339,22 +344,25 @@ def handleExcelRowEntry(self, entry): # subclass MUST override

def parse(self, labels_row_num=None, data_start_row_num=None, ignore_extra=True):
labels_row_num = labels_row_num or self.LABELS_ROW
if ignore_extra:
# ignore data outside of table in spreadsheet file
nrows, ncols = self.getTableBoundaries(labels_row_num)
xl = pandas.read_excel(
self.fname,
sheet_name=self.sheet_name,
skiprows=labels_row_num,
usecols=range(ncols),
nrows=nrows,
)
else:
xl = pandas.read_excel(
self.fname,
sheet_name=self.sheet_name,
header=None,
)
try:
if ignore_extra:
# ignore data outside of table in spreadsheet file
nrows, ncols = self.getTableBoundaries(labels_row_num)
xl = pandas.read_excel(
self.fname,
sheet_name=self.sheet_name,
skiprows=labels_row_num,
usecols=range(ncols),
nrows=nrows,
)
else:
xl = pandas.read_excel(
self.fname,
sheet_name=self.sheet_name,
header=None,
)
except xlrd.XLRDError as exc:
raise ExcelReadError(exc)
self.data_labels = list(map(str, xl.columns.values))
# unused: data_start_row_num = data_start_row_num or labels_row_num+1
for row_data in xl.values:
Expand Down

0 comments on commit 1a9a39a

Please sign in to comment.