A quick hack that should work would be to create a DictReader object to read
the csv with (have a look in the python docs
here<http://docs.python.org/lib/module-csv.html>).
For each row you need to write do:

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

I haven't tested this, but I've used  the csv module a fair bit and th
syntax should be close enough.
Ben

On 22/08/07, Amirouche <[EMAIL PROTECTED]> wrote:
>
>
>
>
> On Aug 21, 8:37 pm, robo <[EMAIL PROTECTED]> wrote:
> > Have any of you guys imported excel/cvs by using Python/Django? I need
> > to import 1000 products for a shopping site and I'd like to learn the
> > fastest and easiest way to do so.
>
> I already did this, but in another way.
> 1. I write Models,
> 2. I parse line by line the csv file (using python library)
> 3. create for each line a Model Instance with the data extracted from
> the file
>
> I prefer, because I had to  change some values, and I prefer to do
> this in python :)
>
>
> >
>


-- 
Regards,
Ben Ford
[EMAIL PROTECTED]
+628111880346

--~--~---------~--~----~------------~-------~--~----~
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