[英]Must both xlrd and xlsxwriter be a up-to-date version to capable transfer cell values from .XLSX files?
Must both xlrd and xlsxwriter be of a minimally recent version capable of working upon .xlsx files? xlrd和xlsxwriter是否都必须是能够处理.xlsx文件的最新版本? I am using respective versions of: xlrd 0.7.4 and xlsxwriter 0.6.0. 我正在使用xlrd 0.7.4和xlsxwriter 0.6.0的各个版本。 In a python script file seeking to gather values from 3 worksheets within an .XLSX file and return summed values in a single sheet output .xlsx file, the script reads as 在一个python脚本文件中,该脚本试图从.XLSX文件中的3个工作表中收集值,并在单个工作表输出.xlsx文件中返回求和的值,该脚本的内容为
import xlrd import xlsxwriter import csv import os from os import walk import glob import shutil import datetime from datetime import datetime os.chdir('S:\\\\Projects\\\\CMP\\\\DataCollectorsWiki\\\\ArchiveofWork\\\\ITC_2007_Group1') root = 'S:\\\\Projects\\\\CMP\\\\DataCollectorsWiki\\\\ArchiveofWork\\\\ITC_2007_Group1' allfiles = [os.path.join(root,f) for root, dirs, files in walk(root) for f in files] ##consolidate all sheets from data workbooks for afile in allfiles: workbook = xlrd.open_workbook(afile) passenger = workbook.sheet_by_index(0) hvyTruck = workbook.sheet_by_index(1) ltTruck = workbook.sheet_by_index(2)
Again, I am using respective versions of: xlrd 0.7.4 and xlsxwriter 0.6.0. 同样,我使用的是xlrd 0.7.4和xlsxwriter 0.6.0的相应版本。 I have read that it is only the xlrd version 0.9.0 that is able to read .xlsx (Excel2007) or subsequent. 我已经读过,只有xlrd 0.9.0版才能读取.xlsx(Excel2007)或更高版本。 Additionally, I have noticed that the .xlsx files I have been working with - when opened in Notepad - begin with either DI or PK - (PK's are actually ZIP files, I've found out). 另外,我注意到我一直使用的.xlsx文件-在记事本中打开时-以DI或PK开头-(我发现PK实际上是ZIP文件)。
So my 2 questions are - 所以我的两个问题是-
1.must both the xlrd and xlsxwriter be both of a certain vintage (version) to properly extract cell value data from .XLSX files and/or: 1. xlrd和xlsxwriter都必须具有一定的年份(版本),才能从.XLSX文件中正确提取单元格值数据和/或:
So my 2 questions are... 所以我的两个问题是...
Yes, the minimum version of xlrd must be at least 0.9.0 (as you say yourself) to read xlsx files. 是的,xlrd的最低版本必须至少为0.9.0(如您自己说的那样)才能读取xlsx文件。 It is probably best to use the latest version of xlrd since it will also contain bug fixes. 最好使用最新版本的xlrd,因为它还会包含错误修复程序。 The XlsxWriter module writes files so you don't need any version of that to extract data from an Excel file. XlsxWriter模块写入文件,因此您不需要该文件的任何版本即可从Excel文件中提取数据。 If you want to write an xlsx file then any version of XlsxWriter will do but the latest version has more features and bug fixes. 如果要编写xlsx文件,则可以使用任何版本的XlsxWriter,但最新版本具有更多功能和错误修复。
It isn't easy to convert xlsx to xls with 100% fidelity outside of Excel. 在Excel之外将xlsx转换为具有100%保真度的xls并不容易。
So if you have a choice between trying to automate Excel on Windows to convert files from one format to another or just upgrading xlrd to a more recent version then the latter seems easier. 因此,如果您可以选择在Windows上自动执行Excel以将文件从一种格式转换为另一种格式,或者只是将xlrd升级到更新的版本,则后者似乎更容易。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.