6👍
Have a look at the xlrd package, which allows you to read Excel files in Python. Once you’ve read the data you can do whatever you want with it, including saving it to the database.
For a basic usage example, look at http://scienceoss.com/read-excel-files-from-python/
3👍
Use django-batchimport http://code.google.com/p/django-batchimport/ It provides a very simple way to upload data in Excel sheets to your Django models. I have used it in a couple of projects. It can be integrated very easily into your existing Django project.
Read the documentation on the project page to know how to use it.
It is built on XLRD.
- [Django]-Django posts and responses
- [Django]-Why am getting a MultipleObjectsReturned error inside a try block?
- [Django]-How to avoid repeated values retrieved from database?
- [Django]-Django loaddata settings error
- [Django]-'ascii' codec can't decode byte 0xe2 in position 5367: ordinal not in range(128)
2👍
Have a look at the presentation “Excel & Python” that Chris Withers gave at PyCon US:
“This lightning talk explains that you don’t need to use COM or be on Windows to read and write native Excel files.”
http://www.simplistix.co.uk/presentations/python_excel_09/excel-lightning.pdf
- [Django]-Django: 'User' object has no attribute 'user'
- [Django]-Django: after form.is_valid check, cleaned_data is missing the image field
- [Django]-Django flatpages and images
- [Django]-Django(Python) AttributeError: 'NoneType' object has no attribute 'split'
0👍
Programatically or manually? If manualy then just save the excel as a CSV (with csv or txt extension) and import into Postgresql using
copy the_data from '/path/to/csv/MYFILE.txt' DELIMITERS ',' CSV;
- [Django]-How can i find if the date lies between two dates
- [Django]-Python & Django on a Mac: Illegal hardware instruction
0👍
As I remember of this.
The best way is to save this sheet as plain text ( CSV or something )
And then load with some custom SQL script.
http://www.postgresql.org/docs/8.3/static/populate.html
- [Django]-Testing a Django app in many separate threads
- [Django]-How to use FilePond in Django project
0👍
Or have a look at SQLAlchemy if you’re going to write some kind of script to help you with that.(http://www.sqlalchemy.org/)
0👍
If you want to use COM to interface excel (i.e. you are running on a Windows machine), see “Migrating Excel data to SQLite” – http://www.saltycrane.com/blog/2007/11/migrating-excel-to-sqlite-using-python/
0👍
I built django-batchimport on top of xlrd which is AMAZING. The only issues I had were with getting data into Django. Had nothing to do with any limitations of xlrd. It rocks. John’s work is incredible.
Note that I’ve actually done some update work to django-batchimport and just released. Take a look: http://code.google.com/p/django-batchimport/
- [Django]-Display different templates based on host in Django
- [Django]-Django: environment variable for SECRET_KEY not working
- [Django]-Django get_object_or_404 is not defined
-1👍
Just started using XLRD and it looks very easy and simple to use.
Beware that it does not support Excel 2007 yet, so keep in mind to save your excel at 2003 format.
- [Django]-Setting a foreign key on a formset on formset.save()
- [Django]-Type object is not iterable Django
- [Django]-Python model inheritance and order of model declaration
- [Django]-No matter what I do, django-admin.py is not found, even though it's in my path
- [Django]-How to show a django ModelForm field as uneditable