Write to CSV issue

it should be a fairly simple code with some math involved so i can write all my rows so i made:

        writer = csv.writer(open("navmesh.csv", "wb"))
        for i in range(bs*bs*9):
            frow = nl[i],nt[i],nl[i],nt[i],gx[i],gy[i],gz[i],px[i],py[i],pz[i]
            writer.writerows(frow)

but when I run this i get the error below:

  File "terraingen.py", line 143, in __init__
    writer.writerows(frow)
_csv.Error: sequence expected

If I can get this working i believe I may have added functionality to PandaAI to use geomip terrain with some work lol. So if anyone can help it would be greatly appreciated!

Solved: (This is more of a python issue than a Panda3d issue so feel free to move the post if needed but please do not delete until March 30th thank you)

import csv

      writer = csv.writer(open("navmesh.csv", "wb")) 
      for i in range(bs*bs*9): 
          frow = nl[i]+','+nt[i]+','+nl[i]+','+nt[i]+','+gx[i]+','+gy[i]+','+gz[i]+','+px[i]+','+py[i]+','+pz[i]
          frow2 = [(frow2)+','+(frow)] 
      writer.writerows(frow2)

This is the simplest way to write to any document although it is not aware of formatting so there are certain contraints in that it must be written as one line seperated by comma’s with each line you want seperated by (), so if you had raw data it would look like below:

data = [
    ("And Now For Something Completely Different", 1971, "Ian MacNaughton"),
    ("Monty Python And The Holy Grail", 1975, "Terry Gilliam, Terry Jones"),
    ("Monty Python's Life Of Brian", 1979, "Terry Jones"),
    ("Monty Python Live At The Hollywood Bowl", 1982, "Terry Hughes"),
    ("Monty Python's The Meaning Of Life", 1983, "Terry Jones")
]

more simple wai is to use picle:

import pickle

#dumps any given structure to file
f = open('data/config.inc', 'w')
pickle.dump(data, f)
f.close() 

#reads any given file and returns exact dumped structure
f = open('data/config.inc', 'r')
data = pickle.load(f)
f.close()