diff --git a/doc/release_notes.rst b/doc/release_notes.rst index a5454c3b..551b8c48 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -316,6 +316,8 @@ Upcoming Release * Mark downloaded files as ``ancient`` rather than ``protected``. +* Fix file name enconding in optional rule :mod:`build_biomass_transport_costs` depending on the operating system. + PyPSA-Eur 0.10.0 (19th February 2024) ===================================== diff --git a/scripts/build_biomass_transport_costs.py b/scripts/build_biomass_transport_costs.py index 9c825c47..085a0f00 100644 --- a/scripts/build_biomass_transport_costs.py +++ b/scripts/build_biomass_transport_costs.py @@ -17,20 +17,27 @@ assuming as an approximation energy content of wood pellets @author: bw0928 """ +import platform + import pandas as pd import tabula as tbl ENERGY_CONTENT = 4.8 # unit MWh/t (wood pellets) +system = platform.system() +encoding = "cp1252" if system == "Windows" else None def get_countries(): - pandas_options = dict(skiprows=range(6), header=None, index_col=0) + pandas_options = dict( + skiprows=range(6), header=None, index_col=0, encoding=encoding + ) return tbl.read_pdf( str(snakemake.input.transport_cost_data), pages="145", multiple_tables=False, pandas_options=pandas_options, + encoding=encoding, )[0].index @@ -41,6 +48,7 @@ def get_cost_per_tkm(page, countries): sep=" |,", engine="python", index_col=False, + encoding=encoding, ) sc = tbl.read_pdf( @@ -48,6 +56,7 @@ def get_cost_per_tkm(page, countries): pages=page, multiple_tables=False, pandas_options=pandas_options, + encoding=encoding, )[0] sc.index = countries sc.columns = sc.columns.str.replace("€", "EUR")