我希望将给定的excel文件转换为csv,使用csvkit作为库,而不是从命令行。我很难找到任何关于库使用语法的信息。有谁能解释一下如何使用csvkit作为库来实现这一目的吗?
我的测试用例很简单-接受input.xlsx或input.xls,转换,然后另存为output.csv。这是我到目前为止尝试过的,它是基于在其他地方找到的建议:
import csvkit
with open('input.xlsx') as csvfile:
reader = in2csv(csvfile)
# below is just to test whether the file could be accessed
for row in reader:
print(row)给出
Traceback (most recent call last):
File "excelconvert.py", line 6, in <module>
reader = in2csv(csvfile)
NameError: name 'in2csv' is not defined还有一个类似的问题here,但答案似乎只是引用了一些文档,这些文档要么没有出现,要么实际上没有解释库使用语法,它只是列出了类。有一个答案表明语法可能类似于csv模块,这是我用来进行上述尝试的模块,但我什么也没得到。
https://stackoverflow.com/questions/41469595
复制相似问题