[英]Py4JJavaError: An error occurred while calling o389.csv
I'm new to pyspark.我是 pyspark 的新手。 I'm running pyspark using databricks.
我正在使用数据块运行 pyspark。 My data is stored in Azure Data Lake Service.I'm trying to read csv file from ADLS to pyspark data frame.
我的数据存储在 Azure 数据湖服务中。我正在尝试从 ADLS 读取 csv 文件到 pyspark 数据框。 So I wrote following code
所以我写了以下代码
import pyspark
from pyspark import SparkContext
from pyspark import SparkFiles
df = sqlContext.read.csv(SparkFiles.get("dbfs:mycsv path in ADSL/Data.csv"),
header=True, inferSchema= True)
But I'm getting error message但我收到错误信息
Py4JJavaError: An error occurred while calling o389.csv.
Can you suggest me to rectify this error?你能建议我纠正这个错误吗?
The SparkFiles
class is intended for accessing the files shipped as part of the Spark job. SparkFiles
类用于访问作为 Spark 作业的一部分提供的文件。 If you just need access to the CSV file available on ADLS, then you just need to use spark.read.csv
, like:如果您只需要访问 ADLS 上可用的 CSV 文件,那么您只需要使用
spark.read.csv
,例如:
df = spark.read.csv("dbfs:mycsv path in ADSL/Data.csv",
header=True, inferSchema=True)
it's better not to use sqlContext
, it's kept for compatibility reasons.最好不要使用
sqlContext
,它是出于兼容性原因而保留的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.