Skip to content

Commit

Permalink
Use utf-8 when printing dd files (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
olejandro authored Mar 5, 2024
1 parent f4b1146 commit 9ea9983
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions xl2times/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ def produce_times_tables(
def write_dd_files(
tables: Dict[str, DataFrame], config: datatypes.Config, output_dir: str
):
encoding = "utf-8"
os.makedirs(output_dir, exist_ok=True)
for item in os.listdir(output_dir):
if item.endswith(".dd"):
Expand Down Expand Up @@ -369,11 +370,13 @@ def convert_parameter(tablename: str, df: DataFrame):
tables_in_file = {
"ts.dd": ["ALL_TS"],
"milestonyr.dd": ["MILESTONYR"],
"output.dd": [t for t in config.dd_table_order if t != "ALL_TS"],
"output.dd": [
t for t in config.dd_table_order if t not in ["ALL_TS", "MILESTONYR"]
],
}

for fname, tablenames in tables_in_file.items():
with open(os.path.join(output_dir, fname), "w") as fout:
with open(os.path.join(output_dir, fname), "w", encoding=encoding) as fout:
for tablename in [t for t in tablenames if t in tables]:
df = tables[tablename]
if tablename in sets:
Expand Down

0 comments on commit 9ea9983

Please sign in to comment.