代码工作簿 - 使用Hadoop_path找不到文件
我有一个正在运行此代码的代码工作簿中的Python变换:
import pandas as pd
def contents(dataset_with_files):
fs = dataset_with_files.filesystem()
filenames = [f.path for f in fs.ls()]
fp = fs.hadoop_path + "/" + filenames[0]
with open(fp, 'r') as f:
t = f.read()
rows = {"text": [t]}
return pd.DataFrame(rows)
但是我会收到错误 filenotfounderror:[Errno 2]没有这样的文件或目录:
我的理解是,这是访问的正确方法HDFS中的文件,这是一个存储库与代码工作簿限制吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该文档帮助我弄清楚了:
<
这实际上是一个很小的变化。如果您使用的是
filesystem()
,则只需要相对路径。还有这个选项,但我发现它慢10倍。
This documentation helped me figure it out:
https://www.palantir.com/docs/foundry/code-workbook/transforms-unstructured/
It was actually a pretty small change. If you are using the
filesystem()
you only need the relative path.There is also this option, but I found it 10x slower.