Comments (7)
OK. I will elaborate more on that in the doc. Thanks for your comments.
In this section, forms.FieldField() tells the UploadFileForm that I will need a form field that accepts a file upload.
And UploadFileForm can be rendered by Django as a html form on your web page and the form instance can also be used to do form validation in the server side.
from django-excel.
Don't get me wrong. I just don't know what big benefit django-excel provides.
I use pyexcel like this now:
class FooForm(forms.Form):
spreadsheet = forms.FileField()
def save(self):
temporary_uploaded_file = self.cleaned_data['spreadsheet']
for row_dict in pyexcel.iget_records(file_stream=temporary_uploaded_file,
file_type=temporary_uploaded_file.name.split('.')[-1]):
do_foo(row_dict['my_col'])
Why should I use django-excel? Why is it better then the way I do?
I like it reusable. I don't like it, if I need to change the config like settings.FILE_UPLOAD_HANDLERS for one app. I run several apps in my project. What should I do, if app Foo wants Foo-Upload-Handler and app Bar wants Bar-Upload-Handler?
from django-excel.
I like your critical thinking. Here is my rationale for django-excel.
django-excel provide two handlers in order to save the time that is to be spent on saving the uploaded file to file system and reading it back for further processing. In particular, MemoryFileUploadHandler would hold the uploaded file in memory. The idea is that ExcelMemoryFileUploadHandler can read excel data from the memory buffer already without saving it to file system first.
Unless you have other means of obtained the uploaded file more efficiently, you can ignore django-excel.
from django-excel.
Thank you for your feedback. And thank you for liking my critical thinking.
Above I provided the lines which I use now.
Do you think there is a more efficient way to use pyexcel and django (without django-excel)?
from django-excel.
Apart from handling file uploads, you can use pyexcel the way you wanted(I mean without using django-excel). The main challenge for pyexcel is how to read and write data quickly. The performance of pyexcel differs in handling data under 1MB, and hundreds of MB, up to multiple GBs. Here is the list of things that I found in configure pyexcel plugins to cope with big data sets: http://pyexcel.readthedocs.io/en/v0.6.0/iodrivers.html#read-and-write-with-performance.
and here:
http://pyexcel.readthedocs.io/en/v0.6.0/two-liners.html
from django-excel.
And when django-excel tries to save the uploaded data into django models, it will use bulk_insert(which is much quicker than saving one by one). However, to be able to use bulk_insert, the developer need to ensure the uploaded data will not cause database exceptions upon db-insersion, typical ones are: database integrity error.
from django-excel.
from django-excel.
Related Issues (20)
- Save to model.FileField a generated xls
- How dow I format individual fields from a queryset in a make_response_from_querysets HOT 1
- How do I ignore a row or column when import data use save_to_database? HOT 2
- Incorrect message on file not found HOT 2
- Doc in Chinese HOT 1
- Unable save table after making changes in the model.py file HOT 1
- Question: How to overwrite the default encoding HOT 3
- Exception Type: IntegrityError Exception Value: UNIQUE constraint failed: myapp_question.slug HOT 2
- Not able to upload large excel or CSV file with the size 10Mb
- Urgent Help: Trying to Import data from two sheets(xlsx) into two different models(Foreign Key Related) - Not able to lead the Data HOT 5
- build failed with django 3.1.1 HOT 8
- jump column HOT 3
- Unable to support XLS and XLSX uploads in Python 3.9 HOT 3
- start test got wrong HOT 2
- Can't get XLSX support working HOT 4
- Import related models without static foreign keys HOT 4
- How to create an import for whole document without defining 'choice' and 'question'?
- Realy? Object of type UUID is not JSON serializable HOT 2
- Django 4.0 forward compatibility Error HOT 1
- <ul class="errorlist"><li>This field is required.</li></ul>
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-excel.