我使用的是 python 2.7
简要总结:我在现有代码中添加代码,该代码可以正常工作。原始代码旨在读取定位路径中的压缩文本文件并打开它。但是,在我工作的开发环境中,没有这样的文件;我自然要做的第一件事就是在路径中保存一个文件:
====> 我保存了一个文件 X = X.txt.zip 文本文件看起来像这样(表格):
import ctypes as ct
dll = ct.CDLL('./test')
dll.add.argtypes = ct.c_int,ct.POINTER(ct.c_long) # pointer type. Note upper case!
dll.add.restype = ct.c_int
mylong = ct.c_long() # create ctypes instance
p_mylong = ct.pointer(mylong) # create pointer to instance. Note lower case!
ret = dll.add(999,p_mylong)
print(ret,mylong.value)
===> FILE X 保存在 PATH_1 ====> 代码集参数 SEL.FILES 列出了路径 X 中的所有文件 ====> 代码还列出了所有文件(位于路径中)及其规范(听者A、文件名、读者):
------------------------------------
| header1 | header2 | header3 |
------------------------------------
| value 1 | value2 | value2 | = REC 1
| value 1 | value2 | value2 | = REC 2
====>PETL 包已使用
====> 代码循环(For 循环)所有文件(见下面的 FOR 循环):
FOR file_rec in PETL.records(self.files): # <=== 循环遍历所有文件 READER = file_rec.READER(file_rec.file_name) # <== 读取文件内部错误!错误 ! 对于 PETL.RECORDS(PETL.ADDROWNUMBERS(READER)) 中的记录: 打印(记录)
我希望得到打印的 REC,如:
|值 1 |值2 |值2 |
|值 1 |值2 |值2 |
错误消息的某些行说:iterrecords hdr = next(it)
-============================================== 请注意,行 PETL.ADDROWNUMBERS(READER)) 在每个 ROW 中添加 ROW 编号
我想了解为什么 << READER>> 无法打开和读取文件 (=file_rec.file_name)???