RamblingMan 2017-08-29 14:20 采纳率: 0%
浏览 2694

spark读取本地文件报错

在scala编写spark程序使用了sc.textFile("file:///home/hadoop/2.txt"),

竟然报错java.io.FileNotFoundException: File file:/home/hadoop/2.txt does not exist,之后又用spark-shell测试,依旧报这样错误

 scala> val rdd = sc.textFile("file:///home/hadoop/2.txt")
rdd: org.apache.spark.rdd.RDD[String] = file:///home/hadoop/2.txt MapPartitionsRDD[5] at textFile at <console>:24
scala> rdd.take(1)
17/08/29 20:27:28 WARN scheduler.TaskSetManager: Lost task 0.0 in stage 1.0 (TID 4, slaves3, executor 2): java.io.FileNotFoundException: File file:/home/hadoop/2.txt does not exist

我cat文件是有输出的

 [hadoop@master ~]$  cat /home/hadoop/2.txt
chen    001     {"phone":"187***","sex":"m","card":"123"}
zhou    002     {"phone":"187***","sex":"f","educetion":"1"}
qian    003     {"phone":"187***","sex":"f","book":"2"}
li      004     {"phone":"187***","sex":"f"}
wu      005     {"phone":"187***","sex":"f"}
zhang   006     {"phone":"187***","sex":"f"}
xia     007     {"phone":"187***","sex":"f"}
wang    008     {"phone":"187***","sex":"f"}
lv      009     {"phone":"187***","sex":"m"}

之后我将文件放在hdfs上面,就能读取的到,这是怎么回事

  • 写回答

1条回答

  • threenewbee 2017-08-30 15:54
    关注
    评论

报告相同问题?

悬赏问题

  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波