Skip to content
Advertisement

How to get data from excel file ‘as is’ using openpyxl?

I have an excel file – the data in which looks like.

JavaScript

I want to get float values ​​of cells – in which separator is comma. But when accessing them, a value with a dot is returned. Is it possible to do this with opepyxl or other libraries?

what i tried

JavaScript

I also tried pandas, but it also formats cells with commas.

Advertisement

Answer

This will set the locale to German, which uses a comma as the decimal separator and a dot as the thousands separator, and then format the float value using this locale.

You can also use ‘fr_FR’ for French, ‘pt_BR’ for Brazilian Portuguese and ‘es_ES’ for Spanish etc.

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement