acruzgarcia / OMIEData

Python package to import data from OMIE (Iberian Peninsula's Electricity Market Operator): https://www.omie.es/
https://pypi.org/project/OMIEData/
MIT License
24 stars 7 forks source link

unsupported locale setting #2

Closed edejuan closed 2 years ago

edejuan commented 2 years ago

Hi @acruzgarcia @mirelmora , congrats on this project! It looks super interesting. I'm very excited to using it, but unfortunately it gives me an error.

I'm launching this piece of code from your examples (I changed the dates to try faster):

import datetime as dt
from OMIEData.DataImport.omie_marginalprice_importer import OMIEMarginalPriceFileImporter

dateIni = dt.datetime(2022, 3, 11)
dateEnd = dt.datetime(2022, 3, 11)

# This can take time, it is downloading the files from the website..
df = OMIEMarginalPriceFileImporter(date_ini=dateIni, date_end=dateEnd).read_to_dataframe(verbose=True)
df.sort_values(by='DATE', axis=0, inplace=True)
print(df)

But I'm afraid I get an error "unsupported locale setting". This is the output:

Requesting https://www.omie.es/sites/default/files/dados/AGNO_2022/MES_03/TXT/INT_PBC_EV_H_1_11_03_2022_11_03_2022.TXT ...
There was error processing file: https://www.omie.es/sites/default/files/dados/AGNO_2022/MES_03/TXT/INT_PBC_EV_H_1_11_03_2022_11_03_2022.TXT
unsupported locale settinghttps://[www.omie.es/sites/default/files/dados/AGNO_2022/MES_03/TXT/INT_PBC_EV_H_1_11_03_2022_11_03_2022.TXT](http://www.omie.es/sites/default/files/dados/AGNO_2022/MES_03/TXT/INT_PBC_EV_H_1_11_03_2022_11_03_2022.TXT)
Empty DataFrame
Columns: [DATE, CONCEPT, H1, H2, H3, H4, H5, H6, H7, H8, H9, H10, H11, H12, H13, H14, H15, H16, H17, H18, H19, H20, H21, H22, H23, H24]
Index: []

I'd really appreciate if you could tell my what I'm doing wrong. Thanks!

edejuan commented 2 years ago

By the way, I'm using Google Colab Pro Thanks!

acruzgarcia commented 2 years ago

Hi @edejuan , thanks for your comment.

The code sets locale to en_DK.UTF-8 to read the files from OMIE:

locale.setlocale(locale.LC_NUMERIC, "en_DK.UTF-8")

so you have to have it installed. i guess they come installed by default in windows systems, but you may need to figure out how to install them in other systems. For instance, in ubuntu is:

sudo apt-get update sudo apt-get install locales

I hope this helps. Let me know how it goes.

acruzgarcia commented 2 years ago

Hi @edejuan, I hope it finally worked. I will close this issue so it does not stay indefinitely opened.

tn2094 commented 2 years ago

Hello Alberto I reopen this issue because I m using pycharm in windows and I can't figure it out how to fix this issue with the format. I looked on forums but didn t found. Any idea on your side pls?

acruzgarcia commented 2 years ago

Hi tn2094, sorry i took so long for me to answer. It looks like the issue is still closed so i didnt see your comment until now...

Did you try to install locales? Could you tell me what OS are you using to run the package? I would like to try to reproduce the issue so please provide as much information as possible.

tn2094 commented 2 years ago

Hola Alberto !

I just tried again but keep on having this error. Maybe do you have a moment to discuss so i can share you my screen and we see? If yes can i send you an invitation via a.cruz.garcia@gmail.com?

Thanks for the help

image

BigTava commented 2 years ago

Hello, I am also having the same error, using a docker container python:3.10.1-slim-buster. Any further developments on this issue?

BigTava commented 2 years ago

Somehow this locale en_DK.UTF-8 was not pre-installed. I solved this issue using the following commands. What made the trick was installing locales-all

RUN apt-get update && \ apt-get install -y locales locales-all && \ dpkg-reconfigure --frontend=noninteractive locales

acruzgarcia commented 2 years ago

Thanks for the additional explanation on how to fix it.