Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

file searching in python

with open('largeFile', 'r') as inF:
    for line in inF:
        if 'myString' in line:
            # do_something
Comment

searching through a file in python

# Open the file
fhand = open('path and the name of the file')
count = 0
# iterate through the lines in the file
for line in fhand:
    # Remove the 
 at the end and stop printing an empty line
    line = line.rstrip()
    if 'sub string' in line:
        count += 1
        print(count, line)
# Close the file
fhand.close()
Comment

python : search file for string

import mmap

with open('example.txt') as f:
    s = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
    if s.find('blabla') != -1:
        print('true')
Comment

PREVIOUS NEXT
Code Example
Python :: how to convert to string in python 
Python :: sieve of eratosthenes python 
Python :: split data train python 
Python :: urllib3 python 
Python :: 13 pseudo random numbers between 0 to 3 python 
Python :: change font size in plt 
Python :: standardise columns python 
Python :: python basic flask app 
Python :: matplotlib position legend 
Python :: how to add rows to empty dataframe 
Python :: get only every 2 rows pandas 
Python :: length of dataframe 
Python :: how to check if a input is an integer python 
Python :: django app 
Python :: plt .show 
Python :: install quick-mailer 
Python :: read binary image python 
Python :: iterate through an array python 
Python :: conda environment 
Python :: read a csv and plot in python 
Python :: pandas change date format to yyyy-mm-dd 
Python :: prime number python program 
Python :: python string indexof 
Python :: python line_profiler 
Python :: STATIC_ROOT 
Python :: softmax function python 
Python :: How to split a text column into two separate columns? 
Python :: creating a pandas df 
Python :: python max key dictionary key getter 
Python :: how to get key of a particular value in dictionary python using index 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =