我有以下代码片段,并且在最后一行rows = list(reader)
上遇到了内存错误
for file in fileList:
fileName, fileExtension = os.path.splitext(file)
if fileExtension == ".csv":
with open(path + '\\' + file, "rU") as f:
reader = csv.reader(f, delimiter=',', dialect="excel")
rows = list(reader)
我还能使用其他方法吗?
答案 0 :(得分:2)
由于您现在已经在注释中指出,您只想修复行的格式,因此,您绝对不需要一次性使用所有行。您应该一次遍历csv阅读器一行,修复该行的格式,将该行写入另一个csv文件,然后继续进行下一行:
(SELECT device.id FROM BaseBundle:Device device WHERE device.ns = vars.ns AND device.idUser IS NOT NULL AND device.idUser != '422' AND device.idUser != '819')