It looks pretty good to me. Are you trying this in a shell? If not that might help you debug. You are missing a ')' at the end of
>>>reader = csv.reader(open("mysite\restaurants.csv") that is probably actually your problem ;-). I was experiencing some strange behavior as I was playing with the csv module just now though but it worked for me with a little test file I made: >>> reader = csv.reader(open("rest.csv")) In [32]: for r in reader: ....: for i in range(7): ....: string += r[i] ....: ....: In [33]: string Out[33]: 'nameaddressphonetypedistancedeliveryalcoholname1123bronx123-1234goodfaryesnoname2123jimmy321-4321friedclosenoyes' On May 31, 4:56 am, andrew_dunn <andrewmd...@gmail.com> wrote: > I'm trying to run a script to import data to my model. All the field > names are correct. What I'm getting is an error message that says my > syntax is incorrect on the line that says "for row in reader:" It says > the error is on the colon. If I remove the colon, it gives a syntax > error on the last "e" on "restaurant_name = row[0]" Here's the code: > > import sys > from django.core.management import setup_environ > sys.path.append('C:\django') > from mysite import settings > setup_environ(settings) > > from mysite.mealfinder.models import Restaurant > > import csv > reader = csv.reader(open("mysite\restaurants.csv") > > for row in reader: > restaurant_name = row[0] > address_name = row[1] > phone_number = row[2] > cuisine_type = row[3] > walking_distance = row[4] > delivery_avail = row[5] > alcohol_avail = row[6] > > Restaurant.objects.get_or_create(Name=restaurant_name, > Address=address_name, Phone = phone_number, Cuisine = cuisine_type, > Walking = walking_distance, Delivery = delivery_avail, Alcohol = > alcohol_avail) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---