**Ben Ford, can you explain a bit more about your code?:

for row in reader:
   obj = MyDjangoModel()
   obj.__dict__ = row
   obj.save()

Correct my interpretation if it's wrong. If my CSV file has columns
"first", "last", "phone", and "email", then MyDjangoModel would
contain those 4 fields. Then, obj.__dict__ = row would contain data
from those 4 CSV column types? I was thinking of something like
obj.first = first_CSV, obj.last = last_CSV, and so on. But the most
important thing first, before I mock your code, I need to import csv
right?

**Aidas Bendoraitis and **Tim Chase, your methods look promising.
Tim, in your code:

   filename = 'foo.tab'
   for i, line in enumerate(open(filename)):
     if i == 0: continue # skip the header row
     (fieldname1, fieldname2, fieldname3 ...
      ) = line.rstrip('\n').split('\t')
     cursor.execute("""
       INSERT INTO app_foo
       (f1, f3, f2)
       VALUES
       (%s, %s, %s)
       """, (fieldname1, fieldname3, fieldname2)
       )

f1, f2, and f3 would be my "first", "last", and "phone", and the
fieldname1 to fieldname3 would be the data from "first", "last", and
"phone"?

**Amirouche, your method is similar to Ben's, could you give me some
examples?

Thanks

-Robo


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to