Custom newline characters when reading files

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
emii
Posts: 3
Joined: Sun Feb 28, 2021 2:41 pm

Custom newline characters when reading files

Post by emii » Tue Apr 06, 2021 4:40 pm

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.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Custom newline characters when reading files

Post by pythoncoder » Wed Apr 07, 2021 4:32 pm

It's unsupported. You'll have to read it as a binary file and parse it yourself, I'm afraid.
Peter Hinch
Index to my micropython libraries.

Post Reply