Saturday, November 12, 2011

Re: Massive import from CSV to Database

On 11/12/2011 07:40 PM, Andre Terra wrote:
> Hello, Fabio
>
> I took a look at django-csv-importer but since my files weren't quite
> clean (or comma separated), I ended up rolling my own solution using
> celery[1], to make the uploading rask asynchronous, and DSE[2], to allow
> for faster bulk imports, as well as a lot of trial and error.

Dear Andre,

thank you very much for your reply.

As for these first attempts, import speed was not my primary concern. I
just didn't think of it, but I'll probably have to change my mind! So,
thank you for your tips!

Nonetheless, I am having some problems with django-csv-importer which I
will be happy to solve.

What I am trying to do is just the "Basic sample" in here:
http://django-csv-importer.readthedocs.org/en/latest/index.html

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 file.csv has just one line: "anthony;35;180.5".
my_csv_list = MyCsvModel.import_data(data = open("file.csv"))

This is the error I get:
ImproperlyConfigured: No field defined. Should have at least one field
in the model.

What am I doing wrong?

All the best to you and everybody who's listening.

Fabio.

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