json - reading the numbers from a flat text files in R -


i have text file following lines:

{"time":"2015-11-15t17:56:45.300","x":93.32,"y":8.6,"s":4.57,"dis":0.45,"on_field":true,"game":{"references":[{"origin":"gsis","id":2015111500}]},"team":{"references":[{"origin":"gsis","id":"5110"}]},"play":{"references":[{"origin":"ngs","id":""}]},"references":[{"origin":"gsis","id":"00-0026189"}]} {"time":"2015-11-15t17:56:45.400","x":93.77,"y":8.48,"s":4.55,"dis":0.47,"on_field":true,"game":{"references":[{"origin":"gsis","id":2015111500}]},"team":{"references":[{"origin":"gsis","id":"5110"}]},"play":{"references":[{"origin":"ngs","id":""}]},"references":[{"origin":"gsis","id":"00-0026189"}]} {"time":"2015-11-15t17:56:45.500","x":94.23,"y":8.36,"s":4.53,"dis":0.47,"on_field":true,"game":{"references":[{"origin":"gsis","id":2015111500}]},"team":{"references":[{"origin":"gsis","id":"5110"}]},"play":{"references":[{"origin":"ngs","id":""}]},"references":[{"origin":"gsis","id":"00-0026189"}]} {"time":"2015-11-15t17:56:45.600","x":94.67,"y":8.23,"s":4.51,"dis":0.46,"on_field":true,"game":{"references":[{"origin":"gsis","id":2015111500}]},"team":{"references":[{"origin":"gsis","id":"5110"}]},"play":{"references":[{"origin":"ngs","id":""}]},"references":[{"origin":"gsis","id":"00-0026189"}]} {"time":"2015-11-15t17:56:45.700","x":95.1,"y":8.08,"s":4.5,"dis":0.46,"on_field":true,"game":{"references":[{"origin":"gsis","id":2015111500}]},"team":{"references":[{"origin":"gsis","id":"5110"}]},"play":{"references":[{"origin":"ngs","id":""}]},"references":[{"origin":"gsis","id":"00-0026189"}]} 

i trying extract date, time, x, y, s, , dis variables , save them in r data frame. think can find way clean shell script read in r hoping there nice trick in r only. thanks

each of lines appear in json format (but not whole file, cannot parse such). return each line list , make list of results

res <- readlines("test.txt") library(jsonlite) allofit <- sapply(res, fromjson) 

which give list of lists (of lists ..) containing data


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -