excel file read and write append xlrd, xlwt, xlutils

  • xlrd  can only be used to read files, not to write files;
  • xlwt  can only be used to write files (can only create files, not open existing files), and cannot be used to read files; but it can overwrite existing files when saving.
  • xlutils  uses  the .copy.copy  method to   copy the files read by  xlrd and then process them to xlwt  ; it is equivalent to   building a bridge between xlrd  and  xlwt ;
  • xlrd version 1.2.0  can read  .xls  files and  .xlsx  files at the same time;
  •  After  xlrd version 2.0.0 , it can only be used to read .xls  files, and no longer supports  .xlsx  files;
  • The more complicated one is  xlrd , followed by  xlwt , and the least content is  xlutils , just use  the .copy.copy  method;

Summary of xlrd, xlwt, and xlutils methods for processing .xls files - Knowing that before the text, xlrd can only be used to read files, not to write files; xlwt can only be used to write files, not to read files; xlutils uses the .copy.copy method to copy the files read by xlrd and then process them with xlwt; it is equivalent to building a bridge between xlrd and xlwt... https://zhuanlan.zhihu.com/p/4 46199184

Python automates the operation of Excel, the most complete in the whole network! - Zhihu ▶ Python Excel library comparison Let's first look at the library comparison that can operate Excel in python (a total of nine libraries): 1. Python xlrd read operation Excel1.1 xlrd module introduction (1) What is the xlrd module? The python operation excel mainly uses the two libraries xlrd and xlwt, that is, xlrd is... https://zhuanlan.zhihu.com/p/459936293 

Use of xlwt:

Form and write, set cell style, set width/background color/alignment, add formula/hyperlink/date, merge rows and columns, add border xlwt operation excel tutorial of python package - sunnyeden - blog garden master how to  operate excel https://www.cnblogs.com/sunnyeden/p/16054204.html

Use of xlutils

1. Copy the original file
2. Obtain the information of the original workbook before copying 3. Obtain
the information of the new workbook after copying 4.
Modify the file content directly after copying 5.
Obtain the index coordinates of all cells 6.
Modify the elements in the
cells 7. (Change) function: read the cell index and modify the elements in the cell 8. (Increase) function: add multiple pieces of
data

The python module uses (29) xlutils_weixin_35688430's blog-CSDN blog_python xlutils The use of xlutils Introduction The xlrd and xlwt modules are mainly for reading and writing excel tables, but some operations and data processing operations still need to be implemented according to the xlutils module. 1. Copy the original file import xlrdfrom xlutils.copy import copyworkbook = xlrd.open_workbook('test.xlsx') # Open the workbook new_workbook = copy(workbook) # Copy the obtained xlrd file object to xlwt object new_workbook.sav https://blog.csdn.net/weixin_35688430/article/details/11 3094453

Excel common operation encapsulation function:

https://www.jb51.net/article/267653.htm    JS+Selenium+excel additional writing, using python to successfully crawl any commodity in Jingdong-Knowledge

which one to choose

  • To process small and medium-sized data, use win32com package or xlwings package, they can basically do what VBA can do
  • To handle large data, use the pandas package
  • For development, use the openpyxl package, it does not depend on Excel, it can work normally without Excel installed on the computer, and it is also cross-platform

Although openpyxl has powerful functions for operating Excel, its read and write performance is too bad, especially when writing large tables, it will take up a lot of memory. After enabling the read_only and write_only modes, its performance has been greatly improved, especially the performance of reading has been greatly improved, making it almost time-consuming.

Pandas regards Excel as a container for data reading and writing, serving its powerful data analysis. Therefore, its reading and writing performance is quite satisfactory, but its compatibility with Excel files is the best. It supports reading and writing of .xls and .xlsx files, and supports a single worksheet in a read-only table.

The library that also supports this function is xlrd, but xlrd only supports reading, not writing, and its performance is not outstanding. It needs to cooperate with xlutils to perform Excel operations.

xlsxwriter has a single function and is generally used to create .xlsx files with moderate writing performance.



 
Link: https://www.zhihu.com/question/504963568/answer/2650990775
 


Link: https://www.zhihu.com/question/504963568/answer/2650990775
 

Guess you like

Origin blog.csdn.net/bigcarp/article/details/128368562