I am inserting roughly 10k documents from a CSV file into a rethinkDB table; the code looks like this
print "inserting records",
with open('input.csv', 'rb') as csvfile:
reader = csv.reader(csvfile, delimiter=',')
for row in reader:
document = # do some stuff to create the document
insert_record(document)
print ".",
As you can see after each insert a dot should be printed on screen to show the progress of the operation. Unfortunately what I see instead is:
- nothing happens for a few seconds
- the "inserting records" and a large number of dots is shown all at once
- nothing happens for a few seconds
- again a number of dots is shown all at once
- 3 - 4 repeat until all docuemnts are inserted
Why are the print commands "cached" and then done in batches and how can I fix it?