- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我现在正在学习Spark。当我尝试加载json文件时,如下:
people=sqlContext.jsonFile("C:\wdchentxt\CustomerData.json")
我收到以下错误:
AttributeError: 'SQLContext' object has no attribute 'jsonFile'
我在 Windows 7 PC 上运行此程序,使用 Spark-2.1.0-bin-hadoop2.7 和 Python 2.7.13(2016 年 12 月 17 日)。
感谢您提出的任何建议。
最佳答案
您可能忘记导入隐式。这就是我的 Scala 解决方案:
def loadJson(filename: String, sqlContext: SqlContext): Dataset[Row] = {
import sqlContext._
import sqlContext.implicits._
val df = sqlContext.read.json(filename)
df
}
关于python - 如何修复此错误 : "SQLContext object has no no attribute ' jsonFile',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41641749/
为什么在 Scala Spark 应用程序中初始化 SQLContext 后导入隐式 SqlContext.implicits._。 当 import 放在 object 之外时,似乎有问题。 我来自
我只是想将文本文件读入 pyspark RDD,我注意到 sqlContext.read.load 之间的巨大差异和 sqlContext.read.text . s3_single_file_inp
我正在使用 Spark Dataframe API 从 NFS 共享加载/读取文件,然后将该文件的数据保存/写入 HDFS。 我有一个包含一个主节点和两个工作节点的三节点 Spark 集群。我的 Sp
我是Spark环境的新手,正在尝试将CSV文件导入Spark 2.0.2。我正在Windows 10上使用pyspark。这是到目前为止的代码 from pyspark.sql.types
我正在学习 Spark 和斯卡拉。我精通java,但对scala不太了解。我正在阅读有关 spark 的教程,并遇到了以下代码行,尚未解释: val sqlContext = new org.apac
我的代码正在从 sqlcontext 中读取数据。该表中有 2000 万条记录。我想计算表中的 totalCount。 val finalresult = sqlContext.sql(“SELECT
我正在使用 pyspark 读取一些 csv 数据以触发 Dataframe。 我尝试按如下方式导入 pyspark 模块: from pyspark.sql import sqlContext 为什
我有一个笔记本 a.pynb,它具有读取 parquet 文件语句的功能。 我在另一个笔记本 b.pynb 中使用 a.pynb,在这个新笔记本中,我调用 a.pynb 的一个函数来读取这个 parq
此代码从给定列表创建数据框: sample_one = [(0, 'mouse'), (1, 'black')] sample_two = [(0, 'cat'), (1, 'tabby'), (2,
我有一个数据框,我想将数据汇总到 7 天内并对某些函数进行一些聚合。 我有一个 pyspark sql 数据框,比如 ------ Sale_Date|P_1|P_2|P_3|G_1|G_2|G_3|
我尝试通过一个简单的 Spark 作业(用 Java 编写)查询 Hive 表。 SparkConf conf = new SparkConf().setMaster("local[*]").setA
我正在尝试在 zeppelin 中使用 sqlContext.jsonFile 访问一些 json 数据... 以下代码执行没有任何错误: import sys.process._ val sqlCo
我的文件中只有 3 个事件(第 3 列)01、02、03。 模式是 unixTimestamp|id|eventType|date1|date2|date3 639393604950|1001|01|
我是新来的 Spark 。我只是想使用 sparksession 或 sqlcontext 解析一个 json 文件。 但是每当我运行它们时,我都会收到以下错误。 Exception in threa
我在 Spark 中使用了 SQL,在这个例子中: results = spark.sql("select * from ventas") 其中ventas是一个数据框,以前像表格一样编目: df.c
运行简单的Spark程序,尝试从HDFS读取CSV时出现NoSuchMethodError。 错误: Exception in thread "main" java.lang.NoSuchMethod
我已经导入了以下模块。我尝试从 sqlCtx.read.format 加载数据,但出现 "IllegalArgumentException: u"Error while instantiating '
我有一个名为 getAge(timestamp:Long) 的方法,我想将其注册为 sql 函数。 我有 sqlContext.udf.register("getAge",getAge) 但它告诉我我
我在具有以下签名的 Scala 对象中有一个函数 def f(v1:Int)(implicit sqlContext: SQLContext) 当我尝试从 spark-shell 调用这个函数时,我这
为了进行比较,假设我们有一个表“T”,其中包含两列“A”、“B”。我们还有一个在一些 HDFS 数据库中运行的 hiveContext。我们制作一个数据框: 理论上,以下哪个更快: sqlContex
我是一名优秀的程序员,十分优秀!