How it works...

The principle of importing from an XLSX file is the same as with CSV. We open the file, read it row by row, and create the Movie objects from the provided data. Here is a detailed explanation:

  • Excel files are workbooks containing sheets as different tabs.
  • We are using the openpyxl library to open a file passed as a positional argument to the command. Then, we read the first sheet from the workbook.
  • Afterward, we will read the rows one by one (except the first row with the column titles) and create the Movie objects from them.
  • Once again, the management command will print out the imported movie titles to the console, unless you set --verbosity=0.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.188.160