0

How i can convert a DStream to an dataframe? here is my actual code

localhost = "127.0.0.1"
addresses = [(localhost, 9999)]
schema = ['event', 'id', 'time','occurence']
flumeStream = FlumeUtils.createPollingStream(ssc, addresses)
counts = flumeStream.map(lambda line: str(line).split(",")) \
        .filter(lambda line: len(line)>1) \
        .map(lambda line: (line[29],line[30],line[67],1)) \
        .foreachRDD(lambda rdd: sqlContext.createDataFrame(rdd))

counts.show()

ssc.start()
ssc.awaitTerminationOrTimeout(62)
ssc.stop()

it gives me the following error:

AttributeError: 'NoneType' object has no attribute 'show'
Imane Jabal
  • 35
  • 1
  • 9

1 Answers1

0

Convert your DStream to RDD and then to DataFrame, ie dstrea.rdd.to_df

Zorigt
  • 21
  • 3