File 在循环中读取文件[julia]?

File 在循环中读取文件[julia]?,file,makefile,julia,hdf5,File,Makefile,Julia,Hdf5,我成功地将文件存储在循环中。现在我有1000个从1到1000的文件,我想读它们,但不起作用 for i in 1:1000 h5open("path to file /file$i.h5", "w") do file write(file, "a", x) # alternatively, say "@write file a" end end for i in 1:1000 h5open(" path to files/file$i.h5", "w

我成功地将文件存储在循环中。现在我有1000个从1到1000的文件,我想读它们,但不起作用

for i in 1:1000
    h5open("path to file /file$i.h5", "w") do file
        write(file, "a", x)  # alternatively, say "@write file a"
    end
end
for i in 1:1000
    h5open("  path to files/file$i.h5", "w") do file
        read(file, "a", x)  # alternatively, say "@write file a"
    end
end
因为它写得很好。但说到阅读,这是行不通的

for i in 1:1000
    h5open("path to file /file$i.h5", "w") do file
        write(file, "a", x)  # alternatively, say "@write file a"
    end
end
for i in 1:1000
    h5open("  path to files/file$i.h5", "w") do file
        read(file, "a", x)  # alternatively, say "@write file a"
    end
end
如何解决这个问题


谢谢你

如果你遇到了错误,你应该把它写在问题中

另外,请先仔细阅读文档:

e、 g。

这里呢

要从文件
read()
中读取,将从自述页面获取两个参数,如本例所示。读取对象也被分配给变量c

c = h5open("mydata.h5", "r") do file
    read(file, "A")
end
要将其放入for循环并读取其中的每个变量,最好构造一个数组或其他结构,将值放在第一位。然后将c赋值并索引到该变量,例如

# initialise c to be 1000 elements X whatever you are reading in then ...
for i in 1:1000
    c[i] = h5open("mydataFilenumber$i.h5", "r") do file
        read(file, "A")
    end
end