Difference between writerow() and writerows() methods of Python csv module

writerow takes an iterable of cells to write:

writerow(["foo", "bar", "spam"])
->
foo,bar,spam

writerows takes an iterable of iterables of cells to write:

writerows([["foo", "bar", "spam"],
           ["oof", "rab", "maps"],
           ["writerow", "isn't", "writerows"]])
->
foo,bar,spam
oof,rab,maps,
writerow,isn't,writerows

So writerow takes 1-dimensional data (one row), and writerows takes 2-dimensional data (multiple rows).

Leave a Comment