Import data from excel spreadsheet to django model

前端 未结 3 1097
花落未央
花落未央 2020-12-29 08:51

I\'m building a website that\'ll have a django backend. I want to be able to serve the medical billing data from a database that django will have access to. However, all of

3条回答
  •  离开以前
    2020-12-29 09:13

    Use http://www.python-excel.org/ and consider this process:

    1. Make a view where user can upload the xls file.
    2. Open the file with xlrd. xlrd.open_workbook(filename)
    3. Extract, create dict to map the data you want to sync in db.
    4. Use the models to add, update or delete the information.

    If you follow the process, you can learn a lot of how loading and extracting works and how does it fits with the requirements. I recommend to you first do the step 2 and 3 in shell to get more quicker experiments and avoid to be uploading/testing/error with a django view.

    Hope this kickoff base works for you.

提交回复
热议问题