for large csv filesyou'll want to use the reader object in for loop this avoids loading the entire file into memory at once for exampleenter the following into the interactive shellimport csv examplefile open('example csv'examplereader csv reader(examplefilefor row in examplereaderprint('row #str(examplereader line_numstr(row)row # [ : ''apples'' 'row # [ : ''cherries'' 'row # [ : ''pears'' 'row # [ : ''oranges'' 'row # [ : ''apples'' 'row # [ : ''bananas'' 'row # [ : ''strawberries'' 'after you import the csv module and make reader object from the csv fileyou can loop through the rows in the reader object each row is list of valueswith each value representing cell the print(function call prints the number of the current row and the contents of the row to get the row numberuse the reader object' line_num variablewhich contains the number of the current line the reader object can be looped over only once to reread the csv fileyou must call csv reader to create reader object writer objects writer object lets you write data to csv file to create writer objectyou use the csv writer(function enter the following into the interactive shellimport csv outputfile open('output csv'' 'newline=''outputwriter csv writer(outputfileoutputwriter writerow(['spam''eggs''bacon''ham'] outputwriter writerow(['helloworld!''eggs''bacon''ham'] outputwriter writerow([ ] outputfile close(firstcall open(and pass it 'wto open file in write mode this will create the object you can then pass to csv writer(to create writer object on windowsyou'll also need to pass blank string for the open(function' newline keyword argument for technical reasons beyond the scope of this bookif you forget to set the newline argumentthe rows in output csv will be double-spacedas shown in figure -