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?