Below is R code that successfully reads the first line of a JSON file
(attached).
However, it is supposed to read 5 lines of the file, not just one. What is the
wrong?
====================
>library("rjson")
>json_file <- "/Users/smcintyremobile/Google Drive/AAShelby/CORRESP/Services
>Research/eWoM references for Ed/yelp_academic_dataset SAMPLE.txt"
>json_data <- fromJSON(paste(readLines(json_file,n=5), collapse=""))
>json_data
$votes
$votes$funny
[1] 1
$votes$useful
[1] 8
$votes$cool
[1] 1
$user_id
[1] "TFm6azL9LLpljgVKx-Vfkw"
$name
[1] "E L."
$url
[1] "http://www.yelp.com/user_details?userid=TFm6azL9LLpljgVKx-Vfkw"
$average_stars
[1] 3.5
$review_count
[1] 12
$type
[1] "user"
"{""votes"":" "{""funny"":" "1, ""useful"": 8, ""cool"": 1}, ""user_id"":
""TFm6azL9LLpljgVKx-Vfkw"", ""name"": ""E L."", ""url"":
""http://www.yelp.com/user_details?userid=TFm6azL9LLpljgVKx-Vfkw"",
""average_stars"": 3.5, ""review_count"": 12, ""type"": ""user""}"
"{""votes"":" "{""funny"":" "3, ""useful"": 8, ""cool"": 2}, ""user_id"":
""5wP11xB6tCITP8WF6S5AsQ"", ""name"": ""Douglas H."", ""url"":
""http://www.yelp.com/user_details?userid=5wP11xB6tCITP8WF6S5AsQ"",
""average_stars"": 4.4814814814814801, ""review_count"": 28, ""type"":
""user""}"
"{""votes"":" "{""funny"":" "2, ""useful"": 7, ""cool"": 1}, ""user_id"":
""TkGjOhYgKWayuQRZ6E6RXQ"", ""name"": ""Ryan N."", ""url"":
""http://www.yelp.com/user_details?userid=TkGjOhYgKWayuQRZ6E6RXQ"",
""average_stars"": 2.8999999999999999, ""review_count"": 11, ""type"":
""user""}"
"{""votes"":" "{""funny"":" "0, ""useful"": 1, ""cool"": 1}, ""user_id"":
""E3CvmaY_mLLIKMmrq9wGZw"", ""review_id"": ""VcpjZFajedVOtCU1nuJlzg"",
""stars"": 3, ""date"": ""2009-11-19"", ""text"": ""I expected a much more
rigorous curriculum but the social work program, although top rated, didn't
live up to that. I had some great professors and one terrible one. There was
lots of reading on top of the field work and a few papers. I made some great
friends here but, in hindsight, I might have looked at more affordable schools.
I know having Columbia on my resume has opened doors but I'm not sure if it was
worth the money. I spent my first year in the old building and the new building
is much better. There's a nice little selection of restaurants nearby for lunch
and happy hour."", ""type"": ""review"", ""business_id"":
""t1wzEPmSY_3I_JVYJnzhxA""}"
"{""votes"":" "{""funny"":" "1, ""useful"": 3, ""cool"": 2}, ""user_id"":
""zSFkfZWK3BgmsWUQvZGPHA"", ""review_id"": ""JRFuDqXIcvJ0T1JuYJVv9w"",
""stars"": 5, ""date"": ""2007-01-30"", ""text"": ""Just a half block from my
office, it's a place I drifted into like a masterless samurai in a stupor when
I was desperately looking for a place to get lunch in 20 minutes.\n\nThe food
here is very good, but I appreciate it because it tastes like similar food does
in Japan. Others may have a preference for certain ways in which Japanese food
has been Americanized, but if you're interested in Japanese food that tastes
the way it does in Japan, this is a great little place.\n\nFor example, I'm
often startled (yes, startled) to be served tempura that has been sitting
around for a few minutes. Like radioactive elements, hot food (especially
things like tempura) have a half-life, only instead of losing half of its
radioactive particles, hot food loses half of its deliciousness. In the case
of tempura, it's very hard for any food to be better than just-cooked tempura.
After about five minutes, you'd take it over eggplant. After ten minutes,
you'd eat it rather than starve. Probably.\n\nAt Matsuri, the tempura is
served immediately, which of course is how it's done in Japan. My years in
Japan made me a bit of a fanatic for hot food, western convention of serving
all food at once be damned.\n\nThe sushi is also good, although any place that
uses fresh fish, actual sushi chefs, japanese rice and the right kind of
vinegar in the rice should produce sushi that is good enough for the great
majority of flavor dullards, including me. When you taste that the fish has
been frozen or when the rice is al dente, you know you've made a wrong turn at
Albuquerque, but that's definitely not the case at Matsuri."", ""type"":
""review"", ""business_id"": ""RiZqeuLN-3y04yh4c20Y0A""}"
"{""votes"":" "{""funny"":" "0, ""useful"": 1, ""cool"": 0}, ""user_id"":
""5Mp_jB8yL3xMfgjFu6Xo3Q"", ""review_id"": ""ry1DOyIlKmjo2gnqY_mvzg"",
""stars"": 3, ""date"": ""2008-06-14"", ""text"": ""Tar Heel Taxi is great when
it comes to scheduling a pick up to or from the airport because they always
arrive on time and get you there quickly. Without an appointment in advance,
though, it is difficult to get them to come pick you up. I forgot to call well
in advance last time I was going to RDU, and they said it wouldn't be a problem
and someone would arrive with in 15 minutes. Much to my disappointment, no one
ever showed up, and I had to beg a friend to take me. Just remember to call
ahead and you will be fine, otherwise try someone else."", ""type"":
""review"", ""business_id"": ""ATqKQHGS-iyNpzks8SV95w""}"
"{""votes"":" "{""funny"":" "0, ""useful"": 5, ""cool"": 4}, ""user_id"":
""04ew1cbDQuHNzclTpyXEWQ"", ""review_id"": ""-RxYszq_CdsxCpDqwJ_FMg"",
""stars"": 5, ""date"": ""2007-11-16"", ""text"": ""I am IN LOVE with this
place. I worked two events here this past week. Utopia has SO much
character!!!! It's split into three sections: The Ice Ultralounge, Shangri-La
and Utopia. Each section has its own personality and somehow everything works
without being too gaudy. Seriously, I would just come here to stare at the
wall. \n\nDidn't really get a chance to partake in the food since I was
working, but the calamari and chicken were pretty good.\n\nIce is the dance
section of the Utopia, and, you guessed it...it's blue and gray/silver. Nice,
spacious dance floor with plenty of mirrors to assure you that you are looking
your best!\n\nUtopia is the \""main\"" room, of course...this is where the
sushi bar is and food is served. This room has SO much going on but somehow it
works. I love it. There are several flat screen TVs around so you can catch up
on the latest game. Waterfall wall that is hot!...Ample seating with a very
sexy section of about 4 or 5 booths in the back. \n\nShangri-La is downstairs.
Bright green walls and modern furniture decorate this cutesy area...it reminds
me of a beautifully furnished basement. There is also a small bar down here.
\n\nWe should have a Yelp event here!!!"", ""type"": ""review"",
""business_id"": ""Lkxmc6NoyERTOrQ7W5GEwQ""}"
"{""busines" "s_id"": ""l7" "H8VGwc08dsqmgm_k7_gw"", ""full_address"":
""504 S Lake Ave\nPasadena\nPasadena, CA 91101"", ""schools"": [""California
Institute of Technology""], ""open"": true, ""categories"": [""Arts & Crafts"",
""Shopping"", ""Framing""], ""photo_url"":
""http://s3-media1.px.yelpcdn.com/bphoto/w9KQKoxAVmON0BboiWqmoQ/ms.jpg"",
""city"": ""Pasadena"", ""review_count"": 9, ""name"": ""FrameStore"",
""neighborhoods"": [""Pasadena""], ""url"":
""http://www.yelp.com/biz/framestore-pasadena"", ""longitude"":
-118.13200378418, ""state"": ""CA"", ""stars"": 2.0, ""latitude"":
34.137199401855497, ""type"": ""business""}"
"{""busines" "s_id"": ""4u" "WVO2xAVZNk6hDVk0QChQ"", ""full_address"":
""10280 N Torrey Pines Rd\nSte 343\nLa Jolla, CA 92037"", ""schools"":
[""University of California - San Diego""], ""open"": true, ""categories"":
[""American (Traditional)"", ""Cafes"", ""Restaurants""], ""photo_url"":
""http://media1.px.yelpcdn.com/static/201012163223336441/img/gfx/blank_biz_medium.gif"",
""city"": ""La Jolla"", ""review_count"": 6, ""name"": ""Come On In Cafe"",
""neighborhoods"": [], ""url"":
""http://www.yelp.com/biz/come-on-in-cafe-la-jolla"", ""longitude"":
-117.2429485, ""state"": ""CA"", ""stars"": 2.5, ""latitude"":
32.890153599999998, ""type"": ""business""}"
"{""busines" "s_id"": ""PJ" "D5FVhRStYMfA9AhsyInw"", ""full_address"":
""622 Main St\nLafayette, IN 47901"", ""schools"": [""Purdue University""],
""open"": true, ""categories"": [""Pubs"", ""Bars"", ""Nightlife"",
""Restaurants""], ""photo_url"":
""http://s3-media1.px.yelpcdn.com/bphoto/rfs59p35vlPo_GoUKLuN-A/ms.jpg"",
""city"": ""Lafayette"", ""review_count"": 39, ""name"": ""Lafayette Brewing
Co"", ""neighborhoods"": [], ""url"":
""http://www.yelp.com/biz/lafayette-brewing-co-lafayette"", ""longitude"":
-86.890403747558594, ""state"": ""IN"", ""stars"": 3.5, ""latitude"":
40.418998718261697, ""type"": ""business""}"
"{""busines" "s_id"": ""ln" "1y4hkJq7eXsId0e3wLkw"", ""full_address"":
""111 S River Rd\nWest Lafayette, IN 47906"", ""schools"": [""Purdue
University""], ""open"": true, ""categories"": [""Bars"", ""Indian"", ""Hookah
Bars"", ""Nightlife"", ""Restaurants""], ""photo_url"":
""http://s3-media1.px.yelpcdn.com/bphoto/wOhana5SWJN8NBtA67ylCQ/ms.jpg"",
""city"": ""West Lafayette"", ""review_count"": 2, ""name"": ""Bombay Hookah
Lounge"", ""neighborhoods"": [], ""url"":
""http://www.yelp.com/biz/bombay-hookah-lounge-west-lafayette"", ""longitude"":
-86.905159999999995, ""state"": ""IN"", ""stars"": 3.0, ""latitude"":
40.421602999999998, ""type"": ""business""}"
"{""busines" "s_id"": ""GW" "S5s8HSm1zjqMLJD7wQLg"", ""full_address"":
""710 S 6th St\nChampaign, IL 61822"", ""schools"": [""University of Illinois -
Urbana-Champaign""], ""open"": true, ""categories"": [""Korean"",
""Restaurants""], ""photo_url"":
""http://s3-media1.px.yelpcdn.com/bphoto/wh-wOPqX7S09lEtBGU9ADQ/ms.jpg"",
""city"": ""Champaign"", ""review_count"": 27, ""name"": ""Woori Jib
Restaurant"", ""neighborhoods"": [], ""url"":
""http://www.yelp.com/biz/woori-jib-restaurant-champaign-2"", ""longitude"":
-88.230300903320298, ""state"": ""IL"", ""stars"": 3.5, ""latitude"":
40.110099792480497, ""type"": ""business""}"
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.