Spark read CSV realtive path -
how can read csv spark using relative path? far using absolute path worked fine (1.6.2, 2.0.1) require loading of data via relative path.
trying read file like
val mynewdf = spark.read .option("header", "true") .option("inferschema", "true") .option("charset", "utf-8") .option("delimiter", ";") .csv("~/myproject/somefolder/data.csv")
results in following exception
path not exist: file:/users/geoheil/source/to/scala/sparkproject/~/myproject/somefolder/data.csv;
so not spark blamed ;) settled on using plain scala relative file path:
var path = "~/myproject/data/data.csv" path = path.replacefirst("^~", system.getproperty("user.home"))
Comments
Post a Comment