Nathalie
Nathalie

Reputation: 1238

Use your own csv file instead of json

I would like to run locally this repository

However I have my own csv file with data which I would like to use instead of the json example.

How is it possible to make it?

Here and example of data

data = data.frame(id = c(1,1,2,2), col = c("before", "after", "before", "after"), text = c("text 3 sentiment","I feel good","Happy","It is a nice day and I feel glad"))

Upvotes: 0

Views: 44

Answers (1)

Carl Boneri
Carl Boneri

Reputation: 2722

I'm not sure... but based off your data...

> read.csv2("file.csv") %>% jsonlite::toJSON(auto_unbox = TRUE, pretty = TRUE)
[
  {
    "id": 1,
    "col": "before",
    "text": "text 3 sentiment"
  },
  {
    "id": 1,
    "col": "after",
    "text": "I feel good"
  },
  {
    "id": 2,
    "col": "before",
    "text": "Happy"
  },
  {
    "id": 2,
    "col": "after",
    "text": "It is a nice day and I feel glad"
  }
] 

Upvotes: 1

Related Questions