Learn Python 3: Writing a csv file

I have issue understanding what does line 31 do. I know that line 33 writes head into the csv file and the for loop below write every row into the csv file. So what does line 33 do? I can see that is probably for instantiating the csv file writer but I don’t really understand what it means by “instantiate”

The csv module separates the potential header of a csv (a row consisting of the fieldnames) from the actual values. In this way you can write csv files with or without the header.

That line writes the field names as a row in your open file-

Ok, I understand. Thank you.

1 Like