Re: re search through a text Vs line

2014-10-05 Thread Dave Angel
Shiva Wrote in message: > OK, > Hi Dave, > > I modified it as below and it works(If there is a way to make this more > efficient please let me know) > Deends on what you mean by efficiency. The big memory efficiency gain was when you got rid of either the read or readlines. Performance

Re: re search through a text Vs line

2014-10-05 Thread Shiva
OK, Hi Dave, I modified it as below and it works(If there is a way to make this more efficient please let me know) By the way I am using Python 3.4 import sys import re def extract_names(filename): path = '/home/LearnPython/exercises/' fullfilename = path+filename print('fullfilenam

re search through a text Vs line

2014-10-05 Thread Shiva
Hi, I am doing a regular expression search for a year through a file. fileextract = open(fullfilename,'r') line = fileextract.read() texts = re.search(r'1\d\d\d', line) print(texts.group()) The above works. However if I do: fileextract = open(fullfilename,'r') line = fileextra