On Sun, Dec 09, 2018 at 03:45:07PM +0530, Asad wrote:
> Hi All ,
>
> I have the following code to search for an error and prin the
> solution .
Please tidy your code before asking for help optimizing it. We're
volunteers, not being paid to work on your problem, and your code is too
ha
On Sun, Dec 09, 2018 at 03:45:07PM +0530, Asad wrote:
> Hi All ,
>
> I have the following code to search for an error and prin the
> solution .
>
> /A/B/file1.log size may vary from 5MB -5 GB
[...]
> The problem I am facing in performance issue it takes some minutes to print
> out the
Asad wrote:
> Hi All ,
>
> I have the following code to search for an error and prin the
> solution .
>
> /A/B/file1.log size may vary from 5MB -5 GB
>
> f4 = open (r" /A/B/file1.log ", 'r' )
> string2=f4.readlines()
Do not read the complete file into memory. Read one line at a time
On 09/12/2018 10:15, Asad wrote:
> f4 = open (r" /A/B/file1.log ", 'r' )
Are you sure you want that space at the start ofthe filename?
> string2=f4.readlines()
Here you read the entire file into memory. OK for small files
but if it really can be 5GB that's a lot of memory being used.
> for i
Hi All ,
I have the following code to search for an error and prin the
solution .
/A/B/file1.log size may vary from 5MB -5 GB
f4 = open (r" /A/B/file1.log ", 'r' )
string2=f4.readlines()
for i in range(len(string2)):
position=i
lastposition =position+1
while True: