简体   繁体   English

Spark:如何迭代 TransformedDStream、DataFrame、RDD、DStream?

[英]Spark: How iterate through TransformedDStream, DataFrames, RDDs, DStreams?

I am getting streams of data from a TCP port which includes date timestamp info1 info2.我从 TCP 端口获取数据流,其中包括日期时间戳 info1 info2。 The data is in one line and I want to split it.数据在一行中,我想拆分它。

I tried to iterate through the DStream.我试图遍历 DStream。 I am getting the following error:我收到以下错误:

TypeError: 'DStream' object is not iterable类型错误:'DStream' object 不可迭代

Then I tried to split and create the dataframe.然后我尝试拆分并创建 dataframe。 I am getting the following error:我收到以下错误:

TypeError: 'TransformedDStream' object is not iterable类型错误:'TransformedDStream' object 不可迭代

I also tried to store the stream of data directly in the dataframe but I am getting the error:我还尝试将数据的 stream 直接存储在 dataframe 中,但出现错误:

'DataFrame' object is not 'iterable' 'DataFrame' object 不是'可迭代'

The end result I want is to get one column for date, one column for timestamp, one column for info1, and one column for info2 and perform SQL queries on the data.我想要的最终结果是获取一列日期,一列时间戳,一列 info1,一列 info2,并对数据执行 SQL 查询。

I would really appreciate the help.我非常感谢您的帮助。

I am getting streams of data from a TCP port which includes date timestamp info1 info2.我从 TCP 端口获取数据流,其中包括日期时间戳 info1 info2。 The data is in one line and I want to split it.数据在一行中,我想拆分它。

I tried to iterate through the DStream.我试图遍历 DStream。 I am getting the following error:我收到以下错误:

TypeError: 'DStream' object is not iterable类型错误:'DStream' object 不可迭代

Then I tried to split and create the dataframe.然后我尝试拆分并创建 dataframe。 I am getting the following error:我收到以下错误:

TypeError: 'TransformedDStream' object is not iterable类型错误:'TransformedDStream' object 不可迭代

I also tried to store the stream of data directly in the dataframe but I am getting the error:我还尝试将数据的 stream 直接存储在 dataframe 中,但出现错误:

'DataFrame' object is not 'iterable' 'DataFrame' object 不是'可迭代'

The end result I want is to get one column for date, one column for timestamp, one column for info1, and one column for info2 and perform SQL queries on the data.我想要的最终结果是获取一列日期,一列时间戳,一列 info1,一列 info2,并对数据执行 SQL 查询。

I would really appreciate the help.我非常感谢您的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM