Page 1 of 1

Custom newline characters when reading files

Posted: Tue Apr 06, 2021 4:40 pm
by emii
I'm working with binary files that already contain "\n" as part of the data, but on a low-memory device that can't hold too much in memory. The "lines" are instead separated by "B5 62" (which is more unlikely to come up).

I know in standard python you can stick "newline=b'\xb5b'" at the end of the open() statement, is there a way to do this in micropython? No worries if not, would just save me a lot of work.

Re: Custom newline characters when reading files

Posted: Wed Apr 07, 2021 4:32 pm
by pythoncoder
It's unsupported. You'll have to read it as a binary file and parse it yourself, I'm afraid.