当前位置: 首页 > 工具软件 > GFile > 使用案例 >

tensorflow tf.io.gfile.GFile readline readlines HDFS

澹台展鹏
2023-12-01

tensorflow是可以直接读写hdfs的,主要有:

tf.io.gfile.GFile(
    name, mode='r'
)   //读写文件

flush()   //写完最好用以下,不然有些还在buff中

close()  //关闭数据流

readline  //读取一行

readlines  //读取所有行返回list,这个有个坑,在文件很大时超慢
优先使用readline,需要判断啥时候结束

fsamp = tf.io.gfile.GFile('hdfs://query', mode='r')

while True:
    line = fsamp.readline()
    if not line:  //读完
        break
    print(line)
 类似资料:

相关阅读

相关文章

相关问答