【发布时间】:2021-09-11 15:37:56
【问题描述】:
我目前正在使用 SparkSession,并被告知 SparkContext 在 SparkSession 中。但是,在编写代码时,它向我显示 SparkSession 中不存在 SparkContext 的错误
下面是我做的代码
import findspark
findspark.init()
from pyspark.sql import SparkSession, Row
import collections
spark = SparkSession.builder.config("spark.sql.warehouse.dir", "file://C:/temp").appName("SparkSQL").getOrCreate()
lines = spark.textFile('C:/Users/file.xslx')
错误如下:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_59944/722806425.py in <module>
----> 1 lines = spark.textFile('C:/Users/samue/bt4221_spark/exercise/week5/customer-orders.xslx')
AttributeError: 'SparkSession' object has no attribute 'textFile'
我目前的版本 发现火花:1.4.2 pyspark:3.0.3
我不认为它与任何版本问题有关。任何帮助是极大的赞赏! :)
【问题讨论】:
标签: apache-spark pyspark apache-spark-sql