I have a script that runs some analysis on files, then write the results to a CSV file. In pseudo code:
while (there are still files to analyze):
do_analysis
writer.writerow({... lots of columns names and the analysis results data... })
If the script completes, the data is indeed in the csv file. But if the script crashes - the files are empty. But the writer.writerow() line is called after each file analysis is complete, so I was expecting to get data in the csv file for all files that were analysed before the crash.
What am I doing wrong?