Code Monkey home page Code Monkey logo

Comments (7)

chfw avatar chfw commented on June 23, 2024

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.

guettli avatar guettli commented on June 23, 2024

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.

chfw avatar chfw commented on June 23, 2024

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.

guettli avatar guettli commented on June 23, 2024

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.

chfw avatar chfw commented on June 23, 2024

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.

chfw avatar chfw commented on June 23, 2024

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.

chfw avatar chfw commented on June 23, 2024

9b79176

from django-excel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.