Search code examples
csvapache-sparkapache-zeppelin

Reading csv files in zeppelin 0.8 + spark


i am trying to read a csv file within a zeppelin note using spark like this (i've also tried multiple syntaxes for the path with \ or //) :

here is my code :

%spark
val button2 = <div class="btn btn-success btn-sm">READ CSV</div>.onClick{() =>
try {
    //val df = spark.read.option("header", "true").csv("C://Users/ut00xzh7/Documents/TEST_CSV_AC_CREATION/ac_lst.csv")
    val df = spark.read.format("com.databricks.spark.csv").option("header", "true").load("C://Users/ut00xzh7/Documents/TEST_CSV_AC_CREATION/ac_lst.csv")
    val res= df.collectAsList()
    AngularModel("result", res)
}

and i get this error :

java.io.IOException: No FileSystem for scheme: C

After having made some research i've seen that i can use %dep to add libraries but i haven't any right to do it so i am kind of stucked on this one.


Solution

  • you need to specify path as file:///C:/Users/..., enforcing the local file scheme in URI. Otherwise the disk C is treated as a scheme of URI (general representation of scheme:authority/path