Skip to content

Instantly share code, notes, and snippets.

@canimus
Created February 4, 2020 23:35
Show Gist options
  • Save canimus/1be38665594014a089df2371c2137c67 to your computer and use it in GitHub Desktop.
Save canimus/1be38665594014a089df2371c2137c67 to your computer and use it in GitHub Desktop.
Custom delimiter file reader
def DataStoreFileReader(file, chunk_size=512, lineterminator=172, delimiter=171):
chunk = ""
while True:
curr = file.read(chunk_size)
chunk += curr
if not curr:
break
if chr(lineterminator) in chunk:
lines = chunk.split(chr(lineterminator))
for line in lines[0:-1]:
yield line
chunk = lines[-1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment