slf-dot-ch / snowmicropyn

A python package to read, export and post process data (*.pnt files) recorded by SnowMicroPen, a snow penetration probe for scientific applications developed at SLF.
https://www.slf.ch/en/services-and-products/research-instruments/snowmicropen-r-smp4-version.html
GNU General Public License v3.0
10 stars 12 forks source link

Fix bug with exporting samples to file on Windows #17

Open m9brady opened 4 months ago

m9brady commented 4 months ago

Using snowmicropyn v1.2.1 installed from pypi

On Windows, the default lineterminator for pandas.Dataframe.to_csv is \r\n. Unfortunately this causes snowmicropyn.Profile.export_samples to produce outputs that look like this:

# Exported by snowmicropyn 1.2.1 (git hash None)
distance [mm],force [N]

0.0000,0.1245

0.0041,0.1218

0.0083,0.1245

0.0124,0.1245

0.0165,0.1245

0.0207,0.1245

0.0248,0.1245

0.0289,0.1245

0.0331,0.1245

0.0372,0.1218

With the change introduced in 06cfe5b, the lineterminator is forced to be \n which produces the following on both Windows and Linux:

# Exported by snowmicropyn 1.2.1 (git hash None)
distance [mm],force [N]
0.0000,0.1245
0.0041,0.1218
0.0083,0.1245
0.0124,0.1245
0.0165,0.1245
0.0207,0.1245
0.0248,0.1245
0.0289,0.1245
0.0331,0.1245
0.0372,0.1218