load a local file to spark using sc.textFile()

前端 未结 4 1691
刺人心
刺人心 2020-12-17 05:02

Question

How to load a file from the local file system to Spark using sc.textFile? Do I need to change any -env variables? Also when I tried the same on my windows

4条回答
  •  青春惊慌失措
    2020-12-17 05:35

    Try changing

    val inputFile = sc.textFile("file///C:/Users/swaapnika/Desktop/to do list")
    

    to this:

    val inputFile = sc.textFile("file:///Users/swaapnika/Desktop/to do list")
    

    I'm also fairly new to hadoop and spark, but from what I gather, when running spark locally on Windows, the string file:/// when passed to sc.textFile already refers to C:\.

提交回复
热议问题