Sunday, November 13, 2011

Re: Massive import from CSV to Database

On 11/13/2011 08:38 AM, Fabio Natali wrote:
[...]
> Here is my try:
>
> ###
> from django.db import models
> from csvImporter.model import CsvModel
>
> class MyCsvModel(CsvModel):
> name = models.CharField()
> age = models.IntegerField()
> length = models.FloatField()
> class Meta:
> delimiter = ";"
>
> my_csv_list = MyCsvModel.import_data(data = open("file.csv"))
> ###

My fault! Here comes the correct version:

###
from csvImporter import fields
from csvImporter.model import CsvModel

class MyCsvModel(CsvModel):
name = fields.CharField()
age = fields.IntegerField()
length = fields.FloatField()
class Meta:
delimiter = ";"
###

Thanks to pyhoster who helped me in spotting out the mistake! And thanks
to Anthony Tresontani for providing django-csv-importer!

Now that I managed to make it work, I'll have some speed tests and
decide if this solution really fits my needs.

Bye!!

--
Fabio Natali

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate