Quantcast
Channel: Active questions tagged utf-8 - Stack Overflow
Viewing all articles
Browse latest Browse all 1045

Why do I receive a "polars.exceptions.InvalidOperationError: file encoding is not UTF-8" error when trying to write_csv with Polars?

$
0
0

The code in the accepted answer of this question is as follows:

import polars as pldf1 = pl.DataFrame({"a": [1, 2], "b": [3 ,4]})df2 = pl.DataFrame({"a": [5, 6], "b": [7 ,8]})with open("out.csv", mode="a") as f:   df1.write_csv(f)   df2.write_csv(f, include_header=False)

In VSCode on my Windows 10 machine, the line df1.write_csv(f) generates the error "polars.exceptions.InvalidOperationError: file encoding is not UTF-8." Can there really be a problem with the encoding or is something else wrong?

More broadly, I would like to append to a .csv file using polars as described in the linked question. Is the toy example above still the recommended approach for doing this?


Viewing all articles
Browse latest Browse all 1045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>