streamlit / files-connection

Apache License 2.0
24 stars 3 forks source link

`read()` does not support encoding #12

Open BettyJJ opened 3 months ago

BettyJJ commented 3 months ago

I have a csv file with characters like 'ø'. When I read the file with read(), the characters are not read correctly. Passing encoding='utf-8' to read() does not work. I have to use open() instead. open() works, but it's a bit inconvenient. I checked the source code, and it should be possible to add encoding support to read(): change with self.open(path, "rt") as f: to with self.open(path, "rt", encoding=encoding) as f:. But of course, it depends on how you want to handle this. I can open a PR if you want. @sfc-gh-jcarroll

sfc-gh-jcarroll commented 3 months ago

Thank you! Yes it makes sense. Yes, would welcome a PR to add encoding= support as a kwarg to the read() method.