beginner to R here.
I have a csv file,
key1 key2 key3 key4 key5 key6
value value value value value
value value value value value
value value value value value
etc,
I would to convert the csv file into this format and save it in a .txt file so i can use it in a bulk upload for a server that requires this format:
{"key1": "value", "key2": "value", "key3": "value", "key4": "value", "key5": "value"}
{"key1": "value", "key2": "value", "key3": "value", "key4": "value", "key5": "value"}
{"key1": "value", "key2": "value", "key3": "value", "key4": "value", "key5": "value"}
Here is what i got so far in Rstudio:
#install packages
install.packages('jsonlite')
#libraries
library(readr)
library(jsonlite)
#import data
plantasia_menu_items <- read_csv("plantasia - menu_items.csv")
#View(plantasia_menu_items)
#to Json format
inJSON <- toJSON(plantasia_menu_items)
table <- fromJSON(inJSON)
print(inJSON)
This yields the data in the following format, but i dont know how to restructure it once i have it in json and then save it:
{"key1": "value", "key2": "value", "key3": "value", "key4": "value", "key5": "value"} {"key1": "value", "key2": "value", "key3": "value", "key4": "value", "key5": "value"} {"key1": "value", "key2": "value", "key3": "value", "key4": "value", "key5": "value"}
It must be one a new line for the server to understand the bulk upload and create a new entry. Stuck for a while now. Any ideas on how to restructure this into a matrix?