read Windows/Unix, write Unix line endings

This commit is contained in:
Martin Diehl 2022-03-27 10:03:47 +02:00
parent f3cf67d3fa
commit 0916922423
2 changed files with 3 additions and 2 deletions

View File

@ -280,7 +280,7 @@ class Table:
else:
shapes[label] = (1,)
data = pd.read_csv(f,names=list(range(len(labels))),sep=r'\s+',lineterminator='\n')
data = pd.read_csv(f,names=list(range(len(labels))),sep=r'\s+')
return Table(shapes,data,comments)

View File

@ -224,7 +224,8 @@ def open_text(fname: FileHandle,
f : file handle
"""
return open(Path(fname).expanduser(),mode,newline='\n') if isinstance(fname, (str, Path)) else fname
return fname if not isinstance(fname, (str,Path)) else \
open(Path(fname).expanduser(),mode,newline=('\n' if mode == 'w' else None))
def natural_sort(key: str) -> List[Union[int, str]]: