Code iteration really slow, why?

I was able to write some code with the help of the community here, but I am having a problem where my python runs through the iterations and writting out really really slow as apposed to my other script that does the same exact thing but that one ran super fast, is there anything noticeable in this code that might be causing that?

with open('c:/file.sql') as inf, open('c:/file.txt','w') as outf:
    for i in xrange(47):
        inf.next()       

    for line in inf:
        data = line.split(',')
        if len(data) < 15:
            inf.next()
        elif len(data) > 35:      
            hash = data[13]
            select = hash[3:len(hash)-1]
            outf.write(select + '\n')

Answers


smaller version of your code:

from itertools import imap, islice
with open('c:/file.sql') as inf, open('c:/file.txt','w') as outf:
    for line in imap(str.strip, islice(inf, 47, None)):
        data = line.split(',')
        if len(data) > 35:
            hash = data[13]
            select = hash[3:-1]
            outf.write(select+'\n')

So taking comments into account... I think this is probably what you want:

with open('c:/file.sql') as inf, open('c:/file.txt','w') as outf:
    for line in itertools.islice(inf, 47, None):
        data = line.split(',')
        if len(data) > 35:      
            outf.writeline(data[13][3:-1])

Need Your Help

Android toast not displayed

java android toast

I am a beginner at android development. I am trying to make toasts work but I can't find anything wrong with the code.

Confused how ajc works with javac

java aop aspectj javac compile-time-weaving

I'm a little confused how the AspectJ compiler, ajc works. To my understanding when talking about CTW, ajc is used to weave aspects into the compiled byte-code - ie: the .class file.