0

So I'm aware that one can iterate on a file, which will read input until new line.

I have a file which does not contain new lines, but is too large to fit into memory. Is there a way to read a file word by word?

The only way I can think of is to read a limited number of bytes, find the last space, and yield the space separated words, while keeping the last not finished word in memory.

Bartlomiej Lewandowski
  • 10,771
  • 14
  • 44
  • 75

0 Answers0