Thursday, March 29, 2018

Re: How to upload and save excel data in database django

Hi, there are few ways to do that, both represented in previous posts.

Simpler one is to export data as CSV since it's simpler to read in Python (Python has built-in CSV reader/writer)

Complex one is to use some library to read Excel files directly. See https://www.datacamp.com/community/tutorials/python-excel-tutorial  for more information.

With anycase, use Django (model) form to put data there - it makes sure that data is valid and is converted format that is suitable for Django. It also eliminates checks of malicious people doing malicious stuff to your system.

And finaly, save the data. Repeat for all data chunks and you're done. It's really that simple.


On Thu, Mar 29, 2018 at 3:54 PM, arvind yadav <developer.arvind2289@gmail.com> wrote:
how to use in django please explain 

On Thursday, March 29, 2018 at 5:51:17 PM UTC+5:30, Lei Zhao wrote:
I think you use the library xlrd to extract data from the Excel file.
The documentation for the library can be found here at
http://xlrd.readthedocs.io/en/latest/ .


On Thursday, March 29, 2018 at 6:03:03 PM UTC+8, arvind yadav wrote:
this is may data format 

from django.db import models
class RegisterMember(models.Model):
    GENDER_CHOICES = (
        ('M', 'Male'),
        ('F', 'Female'),
    ) 
    id = models.AutoField(db_column='ID', primary_key=True) 
    name = models.CharField(db_column='NAME', max_length=255) 
    email = models.CharField(db_column='EMAIL', max_length=255) 
    phone = models.CharField(db_column='PHONE', max_length=5000, blank=True, null=True)
    address = models.CharField(db_column='ADDRESS',max_length=255) 
    gender = models.CharField(max_length=1, choices=GENDER_CHOICES)

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/08275ee8-0245-4317-9b14-449cc92e8b4c%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHn91oewmzXvtO5UrhWjy1H2g%3DbrFcKtUMbiZ7pKggWhSeRiEg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment