-2
{"received":1588687345,"guid":"0CA2F400004","eventtype":"sensor","payload":{"time":1588687345,"sensor":[{"type":"temp","unit":"degc","value":20}]}}
{"received":1588687346,"guid":"0CA2F400004","eventtype":"sensor","payload":{"time":1588687344,"sensor":[{"type":"temp","unit":"degc","value":22}]}}
{"received":1588687346,"guid":"0CA2F400004","eventtype":"sensor","payload":{"time":1588687346,"sensor":[{"type":"temp","unit":"degc","value":22}]}}
{"received":1588687348,"guid":"0CA2F400004","eventtype":"sensor","payload":{"time":1588687347,"sensor":[{"type":"temp","unit":"degc","value":28}]}}
{"received":1588687349,"guid":"0CA2F400004","eventtype":"sensor","payload":{"time":1588687347,"sensor":[{"type":"temp","unit":"degc","value":-667}]}}

all the data are in the first column of the csv file. I would like to convert to readable format such as dataframe, and save with write.csv()? Thanks for your help enter image description here

Dave2e
  • 22,192
  • 18
  • 42
  • 50
DAL
  • 21
  • 5
  • @Onyambu suggested that I ask this question again, but I couldn't tag him in because of insufficient reputations. if you can't help please don't vote against it. – DAL May 29 '20 at 12:51
  • How does your readable format looks like? Give an example how your given input should look like as expected output. – Martin Gal May 29 '20 at 13:26
  • received, guid, eventype, time , type, unit, Value; in a dataframe would be appreciated – DAL May 29 '20 at 13:48
  • I have added an image description under the question. Thank you – DAL May 29 '20 at 13:53
  • Solved: jsonlite::stream_in(textConnection(gsub("\\n", "", df))) – DAL May 31 '20 at 09:50
  • this method didnt work with "readLines" . – DAL May 31 '20 at 09:52

1 Answers1

0
library(jsonlite)

df <- read.csv("example.csv", header = FALSE)

jsonlite::stream_in(textConnection(gsub("\\n", "", df)))
Martin Gal
  • 16,640
  • 5
  • 21
  • 39
DAL
  • 21
  • 5