Skip to content

Commit df955e7

Browse files
committed
Use utf-8-sig for CSV assets - see HEA-196
utf-8-sig is required for Pandas to write the UTF BOM into the file, which is required for Excel to recognize the encoding when it opens the file.
1 parent 833735e commit df955e7

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

pipelines/resources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def dump_to_path(self, context: OutputContext, obj: pd.DataFrame, path: UPath) -
125125
context.log.warning(f"Removing existing file: {path}")
126126
self.unlink(path)
127127

128-
obj.to_csv(path, index=False)
128+
obj.to_csv(path, index=False, encoding="utf-8-sig") # Use UTF-8 with BOM for improved Excel compatibility
129129

130130
def load_from_path(self, context: InputContext, path: UPath) -> pd.DataFrame:
131131
return pd.read_csv(path)

0 commit comments

Comments
 (0)