Skip to content

Instantly share code, notes, and snippets.

@lesandie
Created November 28, 2021 10:05
Show Gist options
  • Save lesandie/d9c4134147b18b68bd40ec955c27350c to your computer and use it in GitHub Desktop.
Save lesandie/d9c4134147b18b68bd40ec955c27350c to your computer and use it in GitHub Desktop.
File buffering example
# Simple line buffering example
# When using the context maganet with,
# simply use a 1 to open the file in buffering mode
filename = "input_file.txt"
with open(filename, 'r', 1) as filehandle:
filecontent = filehandle.buffer
for line in filecontent:
line = line.decode()
line = line.strip()
print(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment