dgbowl / yadg

yadg: yet another datagram
https://dgbowl.github.io/yadg
GNU General Public License v3.0
36 stars 13 forks source link

Error: Unsipported locale settings #151

Closed NilsBuett closed 4 months ago

NilsBuett commented 6 months ago

Hello,

I try doing:

extract(filetype="eclab.mpt", path="myfile.mpt")

and get: Error: unsupported locale setting

My data file contains data decimal separator as comma. This should be changed to dots.

Thank you in advance :)

PeterKraus commented 6 months ago

Hello Nils, glad you made it here :)

Could you let me know more info about your set-up - which platform, which locale (or LC_NUMERIC to be exact)?

NilsBuett commented 6 months ago

Hello Peter,

I am working on windows 11 (if that is your question about the platform). I get the following terminal outpurt when I ask about locale.

LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_ALL=
PeterKraus commented 6 months ago

Hi Nils, That's strange. Are you using WSL to run yadg? It looks like you only have the en_US locale installed, but that's also the Linux/UNIX locale, not a Windows one (those are something like English_United States).

I think the current solution within yadg using the locale module might not be ideal, as it requires the appropriate locales to be generated, and has side effects. You can generate the German one using:

sudo locale-gen de_DE.UTF-8 en_GB.UTF-8

And then maybe it would work. However, I have an idea on how to fix it properly using babel instead of locale.

If possible, could you share the file with me? If you don't want to have it publicly shared, please send it to me at peter.kraus@tu-berlin.de.

NilsBuett commented 6 months ago

Hello Peter,

I have send you an e-mail with the data file.

PeterKraus commented 5 months ago

Thanks Nils, I'll try to have a look as soon as possible.

PeterKraus commented 5 months ago

Hi @NilsBuett, your files should work now. Please try installing the current master version of yadg, using:

pip install git+https://github.com/dgbowl/yadg.git

and then you should be able to extract your data as a xarray.Dataset:

from yadg.extractors import extract
ds = extract(filetype="eclab.mpt", path=..., locale="de_DE")

Finally, before closing the issue, please let me know if it works and if I can add your mpt file into the public test database; if you also have the mpr file from which the mpt was generated, that would be very helpful.

NilsBuett commented 5 months ago

Hello Peter,

today I had a deeper view on the results. Unfortunately, the current header name is not given, it is empty. That is for now the only problem I recognized.

PeterKraus commented 5 months ago

@NilsBuett I don't follow - what current header?

NilsBuett commented 5 months ago

@PeterKraus It was my mistake. I have overlooked something. At some files I get and KeyError: "Analog OUT/V"

This may be an Ec-Lab problem that is newer than 11.50...

PeterKraus commented 5 months ago

Analog OUT is not defined as a known column for mpt files, yet, so the code crashes with a KeyError. Probably added in 11.50, or we have not seen it in our test files, yet. It's a fairly easy fix, you will have to add it in this file:

https://github.com/dgbowl/yadg/blob/14ffa12b836eade49a1d2410e6fd4cce7c7aa917/src/yadg/extractors/eclab/common/mpt_columns.py#L28-L31

Feel free to make a PR!