smithsf22 0 Newbie Poster

Hello,
I am trying to export a SELECT statement to a csv file. I have got it work like so:

for row in context.sqlTestExport():
    print "%s,%s,%s,%s,%s" % (row.ID, row.test1, row.test2, row.test3 , row.test4)
  RESPONSE.setHeader("Content-type","application/vnd.ms-excel")
  RESPONSE.setHeader("Content-disposition","attachment;filename=SelectTest.csv")
  return printed

it does return the csv file that I want. The problem is that when I then try to bulk insert it into SQL it errors everytime on the last column of the first row.
It happens when I change the SELECT to get different data and a different amount of rows.

I can fix it by opening the csv file deleting the last row in the first column and typing it back in. I can then do the bulk insert and it works.

I am gussing that the problem is in how I am creating the csv file in the .setHeader but that is just a guess.

Thanks for the help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.