Hi Su,
jsonFile method in Spark-SQL(1.3.1) only expect the path to file.also make sure 
that when you store data in HDFS your json data should be one object per line
for more details follow the link 
SQLContext (Spark 1.3.1 JavaDoc)
jsonFile(String path)Loads a JSON file (one object per line), returning the 
result as a DataFrame. 
if you plan to use Spark(1.4.0) these methods are deprecated you should use 
read method.
https://spark.apache.org/docs/latest/api/java/org/apache/spark/sql/SQLContext.html#read()https://spark.apache.org/docs/latest/api/java/org/apache/spark/sql/DataFrameReader.html#json(java.lang.String)


Nihal
 


     On Tuesday, 30 June 2015 10:40 AM, Su She <suhsheka...@gmail.com> wrote:
   

 Thanks Nihal! This is how I tried it, but I am trying to pull my json file 
from a URL, so I can't do (s"http://ip.json";). If you know any easy fix to this 
(other than saving the file), please let me know, if not no worries, as I'm 
also going to have this data in hdfs/hive.

the code i tried was:
val url = new URL("http://rest.json";)
val content = fromInputStream(url.openStream).getLines.mkString("\n")
val  x = sqlContext.jsonFile(content)


On Mon, Jun 29, 2015 at 9:53 PM, Nihal Bhagchandani 
<nihal_bhagchand...@yahoo.com> wrote:

Hi Su,
following is the code which I have used to access JSON file in zeppelin
//load tweets Json Data as DataFrame
val jfile = sqlContext.jsonFile(s"file:///local/path/on/my/machine/data.json")

//print the schema for jFile DataFrame
jfile.printSchema

//since jfile holds the data in DataFrames we can directly register this data 
as table
jfile.registerTempTable("jTable")
 hope this helps...
Nihal



     On Tuesday, 30 June 2015 12:50 AM, Su She <suhsheka...@gmail.com> wrote:
   

 Hello Nihal,
Quick question, how were you able to read data from a Json file? I've been 
unable to import "play.api.libs.json".
Thanks!
Best,
Su
On Fri, Jun 26, 2015 at 9:00 AM, Nihal Bhagchandani 
<nihal_bhagchand...@yahoo.com> wrote:

Sure, I am just waiting for my zeppelinhub.com credentials.This whole data come 
from 2 files.1. CSV file where I kept all the session related data.2. Json file 
where I kept all the sentiments related data for each session, we collected the 
live tweets and calculated the sentiments. After the whole event ends we 
transfer the data from mongodb to this json file.
I have used zeppelin to show sentiments of each session along with the word 
cloud of hash tags participants used during that session.
Kevin: please let me know which part you are keen on I would try to help for 
sure.
Thanks once again for the support moon and all the zeppelin team you guys 
rock...!
-Nihal

Sent from my iPhone
On 26-Jun-2015, at 20:48, moon soo Lee <m...@apache.org> wrote:


Wow!Thanks for sharing the screen! 

Best,moon

On Fri, Jun 26, 2015 at 8:06 AM Kevin (Sangwoo) Kim <kevin...@apache.org> wrote:

Geat job!!
could you share some codes you've working on too??

2015년 6월 26일 (금) 오후 6:54, Nihal Bhagchandani <nihal_bhagchand...@yahoo.com>님이 
작성:

Hi Team,
thanks for working on this awesome tool...I have been using this tool since 
last 2 weeks or so... attached is the visualization which I able to achieved so 
far...
Nihal
 








   



  

Reply via email to