Until the first file object is flushed/closed, the file content may not be in the file.
>>> f = open('text.csv', 'w+')
>>> f.write('asdf')
>>>
>>> f2 = open('text.csv', 'r')
>>> f2.read()
''
>>> f2.close()
After close
:
>>> f.close()
>>> f2 = open('text.csv', 'r')
>>> f2.read()
'asdf'
Because you open the file with w+
mode, you can use that file object to read the content:
with open(cr_file, 'w+') as f:
c = pycurl.Curl()
c.setopt(c.URL, csv_url)
c.setopt(c.WRITEFUNCTION, f.write)
c.setopt(c.HTTPHEADER, headers)
c.perform()
f.seek(0)
ids = find_bugs(f.readlines())