views:

83

answers:

3

Here is a sample of the first row:

link,Title,Description,Keywords

It is made from an excel workbook, I tried saving in all CSV formats (window, ms-dos, and comma delimited list) I even tried saving in 2 txt file formats (window, ms-dos)

k... here is the code:

csvReader = csv.reader(file('files/my_file.csv', "rU"), delimiter=',')

I must have the U otherwise I get the universal new line error

k... here is the error:

16:56:25,085 ERROR [__main__] Script Error: syntax error at or near "."
LINE 1: ...escription, meta_keywords) VALUES ('link', 'Title'. 'Descrip...
                                                             ^

16:56:25,085 ERROR [__main__] Script Error: syntax error at or near "."
LINE 1: ...escription, meta_keywords) VALUES ('link', 'Title'. 'Descrip...

grumbles Do you see...for some reason, when it goes through the csv.reader function, first comma is OK, second comma becomes a period!

Anyone ever run into this?

+2  A: 

Dalkes comment above dropped the coin for me:

You are reading from a CSV file, and taking that data and inserting in an SQL database, evidently, although you did not say so. You have a syntax error in your SQL-statement.

Note that most SQL databases have CSV imports, so you don't need to write them. Also note that you evidently are trying to import the first row, which contains column headings. That's surely incorrect.

This all shows that it's important on Stackoverflow to show real code that has the problem. Narrow down the code until you can show your problem in code that's small enough to paste here.

99% of the time you'll find the error while doing that.

Lennart Regebro
A: 

The csv.reader is not responsible for constructing the SQL statement whose fragment is being shown in the error message you posted -- some other part of your code must be the one that constructs this statement, and it's doing that in the wrong way. So don't think about csv.reader, but about what you do with the tuples it's returning to the rest of your code!-)

Alex Martelli
A: 

it is the values statement! geez, but I did a log.debug and didn't see it output which was before the sql ...but that is most def what it is. I wasn't trying to import the first row, I plugged that in there purposely to not show actual data. Sorry for the inconvenience. I didn't think the code was making it past that line I did post. And it is the real code all but the file name. I am new to Python, not SQL, so I was sure it was the csv.reader since it is so foreign to me. Thank you guys for your help.

KacieHouser