Allow loading of Neware datasets from parent dirs
This commit is contained in:
parent
132bc7274b
commit
9f9d364a2f
1 changed files with 8 additions and 7 deletions
|
|
@ -7,10 +7,10 @@ import os
|
||||||
import nafuma.auxillary as aux
|
import nafuma.auxillary as aux
|
||||||
from sympy import re
|
from sympy import re
|
||||||
|
|
||||||
def read_data(data, options=None):
|
def read_data(data, options={}):
|
||||||
|
|
||||||
if data['kind'] == 'neware':
|
if data['kind'] == 'neware':
|
||||||
df = read_neware(data['path'])
|
df = read_neware(data['path'], options=options)
|
||||||
cycles = process_neware_data(df=df, options=options)
|
cycles = process_neware_data(df=df, options=options)
|
||||||
|
|
||||||
elif data['kind'] == 'batsmall':
|
elif data['kind'] == 'batsmall':
|
||||||
|
|
@ -25,7 +25,7 @@ def read_data(data, options=None):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def read_neware(path, summary=False):
|
def read_neware(path, options={}):
|
||||||
''' Reads electrochemistry data, currently only from the Neware battery cycler. Will convert to .csv if the filetype is .xlsx,
|
''' Reads electrochemistry data, currently only from the Neware battery cycler. Will convert to .csv if the filetype is .xlsx,
|
||||||
which is the file format the Neware provides for the backup data. In this case it matters if summary is False or not. If file
|
which is the file format the Neware provides for the backup data. In this case it matters if summary is False or not. If file
|
||||||
type is .csv, it will just open the datafile and it does not matter if summary is False or not.'''
|
type is .csv, it will just open the datafile and it does not matter if summary is False or not.'''
|
||||||
|
|
@ -34,17 +34,18 @@ def read_neware(path, summary=False):
|
||||||
# FIXME Do a check if a .csv-file already exists even if the .xlsx is passed
|
# FIXME Do a check if a .csv-file already exists even if the .xlsx is passed
|
||||||
|
|
||||||
# Convert from .xlsx to .csv to make readtime faster
|
# Convert from .xlsx to .csv to make readtime faster
|
||||||
if path.split('.')[-1] == 'xlsx':
|
if path.endswith('xlsx'):
|
||||||
csv_details = ''.join(path.split('.')[:-1]) + '_details.csv'
|
csv_details = ''.join(path[:-5]) + '_details.csv'
|
||||||
csv_summary = ''.join(path.split('.')[:-1]) + '_summary.csv'
|
csv_summary = ''.join(path[:-5]) + '_summary.csv'
|
||||||
|
|
||||||
|
|
||||||
if not os.path.isfile(csv_summary):
|
if not os.path.isfile(csv_summary):
|
||||||
Xlsx2csv(path, outputencoding="utf-8").convert(csv_summary, sheetid=3)
|
Xlsx2csv(path, outputencoding="utf-8").convert(csv_summary, sheetid=3)
|
||||||
|
|
||||||
if not os.path.isfile(csv_details):
|
if not os.path.isfile(csv_details):
|
||||||
Xlsx2csv(path, outputencoding="utf-8").convert(csv_details, sheetid=4)
|
Xlsx2csv(path, outputencoding="utf-8").convert(csv_details, sheetid=4)
|
||||||
|
|
||||||
if summary:
|
if options['summary']:
|
||||||
df = pd.read_csv(csv_summary)
|
df = pd.read_csv(csv_summary)
|
||||||
else:
|
else:
|
||||||
df = pd.read_csv(csv_details)
|
df = pd.read_csv(csv_details)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue