Created
          November 28, 2021 10:05 
        
      - 
      
- 
        Save lesandie/d9c4134147b18b68bd40ec955c27350c to your computer and use it in GitHub Desktop. 
    File buffering example
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # 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