Is it a one-time import or are you looking to have a form that accepts CSV files?
Either way, I would start with the Python csv module. Works really well and should be able to convert your CSV file to a standard Python list of lists, which you should be able to coerce into models, etc.
https://docs.python.org/2/library/csv.html
Write a small script outside of Django that reads a file representing the typical CSV format you are expecting. Once that is working, you can incorporate the code from that script into a model or form. If you only need to import a CSV file one time, just modify that script to bootstrap the Django libraries and modules, then create your model instances from there.
You can also write directly to SQLite directly at that point if needed.
-James
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPCf-y5Nk_ATFgYk-hduiLsrxBasS%3Dzu4Qj8Gp5F9vo%3DNRwF%2BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2By5TLbaBcs8%2BrJsNmXFknRGNTC5%2BOr3URs53eiFBM8GLekmcA%40mail.gmail.com.
/var/www/html/env/local/lib/python2.7/site-packages/django/core/handlers/base.py
in get_response
/var/www/html/webapp/csvapp/views.py
in readcsvfile
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPCf-y74u7NDyxxG_c7rvpver7GKmg-X9CNv-ZJpmug%3Dop3LFA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2By5TLY_BPTQieu%3D%3Dc_hg4ahAGJevp%2B5zb%3D1PWOw5GJ-4ULZ3w%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPCf-y7ky9f7PrpnHvK70yLAMiHaw4s3U500RAdyJV25bdpbag%40mail.gmail.com.
Ah, I suppose that bit didn't get sent. Google groups only lets mail from my old gmail address through and bounces mail from the MIT address I use by default.I noticed something else about your code: you are assigning 2-tuples to all of your data types rather than strings when you do
data.PersonID=row[0],
data.FirstName=row[1],
data.LastName=row[2],
data.Address=row[3],
You might actually be aware of this, but I once spent 4 hours debugging before I realized this on a previous project.
weapons = ('fear', 'surprise', 'fanatical devotion to the pope',) n
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2By5TLab49_vfB%3D8ysOLm22tXXXXrOsaKYGoRQvzis_1PbsX3Q%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPCf-y4zOzVi_uw9jQcmmHy3GVXWukYvu-bKP3HK-G0JB_Zt0Q%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2By5TLbAx_e_LexuC6AOe3LBXWoV2O9GQZpYygSHJrTFF2xagQ%40mail.gmail.com.
Remove comma from each line inside the for loop.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPCf-y4-TXxS9kPQQYUpTzmPP4ts7u__4V_FdPviOE6kYvzoKg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHqTbjma6H4BLtSz2ghLExnMeo1rTzBpV8gShB18TdKyCogBJQ%40mail.gmail.com.