If it is “pretty large” file, then access the lines sequentially and don’t read the whole file into memory:
with open('largeFile', 'r') as inF:
for line in inF:
if 'myString' in line:
# do_something
More Related Contents:
- IndexError: list index out of range How can i solve this and make it run? [duplicate]
- Loading JSON file Using Python Utils Library
- What happens when start value < end value with range() cmd in Python?
- Remove specific characters from a string in Python
- Add a prefix to all Flask routes
- Determining application path in a Python EXE generated by pyInstaller
- Python regex matching Unicode properties
- Does Python support multithreading? Can it speed up execution time?
- Remove and Replace Printed items [duplicate]
- Embedding a matplotlib figure inside a WxPython panel
- Assigning to variable from parent function: “Local variable referenced before assignment” [duplicate]
- Log into gmail using Selenium in Python
- jumping too fast?
- How to copy a python class?
- How to pass an argument to a function pointer parameter?
- How to output CDATA using ElementTree
- difference between filter with multiple arguments and chain filter in django
- Re.match() returns always none
- increase the linewidth of the legend lines in matplotlib
- PermissionError: [Errno 1] Operation not permitted after macOS Catalina Update
- Cron job: how to run a script that requires to open display?
- How to move a sprite according to an angle in Pygame
- Python UTF-16 CSV reader
- What SOAP libraries exist for Python 3.x? [closed]
- How to get the name of an exception that was caught in Python?
- Generating sine wave sound in Python
- Best way to return a value from a python script
- Why Python built in “all” function returns True for empty iterables?
- Installing theano on Windows 8 with GPU enabled
- Can I perform dynamic cumsum of rows in pandas?