如何在Windows上的Spark中访问本地文件? [英] How to access local files in Spark on Windows?
本文介绍了如何在Windows上的Spark中访问本地文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Windows
上使用Spark
.我在*nix
中知道,访问本地文件的代码是这样的:
I am using Spark
on Windows
. I know in *nix
, accessing local file code likes this:
val textFile = sc.textFile("file:///usr/local/spark/README.md")
但是如何访问Windows
上的本地文件?我尝试了以下方法:
But how can I access a local file on Windows
? I have tried following methods:
val logFile = "C:\spark-1.3.1-bin-hadoop2.4\README.md"
val logFile = "file\\C:\spark-1.3.1-bin-hadoop2.4\README.md"
但所有方法都无法正常工作.
But all can't work.
推荐答案
不幸的是,在Windows中,您必须转义"\"
.
Unfortunately in windows you have to escape "\"
.
尝试:
"C:\\spark-1.3.1-bin-hadoop2.4\\README.md"
这篇关于如何在Windows上的Spark中访问本地文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文