Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:ebranlard/weio into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ebranlard committed Sep 27, 2024
2 parents 44f15f3 + 36c7c60 commit 59e74d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
python -m unittest discover -v # run test
""",
long_description_content_type = 'text/markdown',
packages=find_packages(include=['weio'],exclude=['./__init__.py']),
packages=find_packages(include=['weio', 'weio.wetb*', 'weio.tools'],exclude=['./__init__.py']),
install_requires=[
'matplotlib',
'openpyxl',
Expand Down
10 changes: 8 additions & 2 deletions weio/fast_output_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ def readline(iLine):
cols=[n+'_['+u.replace('sec','s')+']' for n,u in zip(info['attribute_names'], info['attribute_units'])]
else:
cols=info['attribute_names']

self.description = info.get('description', '')
self.description = ''.join(self.description) if isinstance(self.description,list) else self.description
if isinstance(self.data, pd.DataFrame):
self.data.columns = cols
else:
Expand All @@ -175,10 +176,15 @@ def write(self, filename=None, binary=None, fileID=4):
else:
# ascii output
with open(self.filename,'w') as f:
f.write(self.description) # add description to the begining of the file
f.write('\t'.join(['{:>10s}'.format(c) for c in self.channels])+'\n')
f.write('\t'.join(['{:>10s}'.format('('+u+')') for u in self.units])+'\n')
# TODO better..
f.write('\n'.join(['\t'.join(['{:10.4f}'.format(y[0])]+['{:10.3e}'.format(x) for x in y[1:]]) for y in self.data]))
if self.data is not None:
if isinstance(self.data, pd.DataFrame) and not self.data.empty:
f.write('\n'.join(['\t'.join(['{:10.4f}'.format(y.iloc[0])]+['{: .5e}'.format(x) for x in y.iloc[1:]]) for _, y in self.data.iterrows()]))
else: # in case data beeing array or list of list.
f.write('\n'.join(['\t'.join(['{:10.4f}'.format(y)]+['{: .5e}'.format(x) for x in y]) for y in self.data]))

@property
def channels(self):
Expand Down

0 comments on commit 59e74d7

Please sign in to comment.