Skip to content

Commit

Permalink
Adapt to kai's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnoe committed Mar 28, 2017
1 parent a989dd3 commit c52563d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions fact/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
log = logging.getLogger(__name__)


allowed_extensions = ('.hdf', '.hdf5', '.h5', '.json', '.csv')
allowed_extensions = ('.hdf', '.hdf5', '.h5', '.json', '.jsonl', '.jsonlines', '.csv')
native_byteorder = native_byteorder = {'little': '<', 'big': '>'}[sys.byteorder]


Expand All @@ -34,13 +34,16 @@ def write_data(df, file_path, key='table'):
elif extension == '.json':
df.to_json(file_path)

elif extension in ('.jsonl', '.jsonline'):
df.to_json(file_path, lines=True, orient='records')

elif extension == '.csv':
df.to_csv(file_path, delimiter=',', index=False)

else:
raise IOError(
'cannot write tabular data with format {}. Allowed formats: {}'.format(
extension, 'hdf5, json, csv'
extension, allowed_extensions,
)
)

Expand Down

0 comments on commit c52563d

Please sign in to comment.