Use rows_to_keep in a loop to build a list with the new sequence of values you want to write out. Then pass that list to writerow(); it doesn't accept an arbitrary number of arguments, so you must call it with a list one way or another. Something like this: