Q:

How to read CSV of JSON strings in R

I have a file which consists different JSON strings in rows, the format of this file is CSV, I want to import all these JSON strings into R but unable to find a successful way, I want to avoid solutions where i have to convert csv into a JSON first.

{"color":"Black","size":"","material":"Georgette","occasion":"Party","rise":"","length":"","pattern":"Embroidered","sleeve":"","neck_type":"","fit":"","bra_type":"","wiring":"","color_filter":"Black","type_filter":"Semi-Stitched","gender":"Women","designed_by":"","article_identifier_type":"","article_identification_value":"","product_dimension":""}

2.{"color":"Blue","size":"","material":"Georgette","occasion":"Party","rise":"","length":"","pattern":"Embroidered","sleeve":"","neck_type":"","fit":"","bra_type":"","wiring":"","color_filter":"Blue","type_filter":"Semi-Stitched","gender":"Women","designed_by":"","article_identifier_type":"","article_identification_value":"","product_dimension":""}
3.{"color":"White","size":"","material":"Cotton","occasion":"Ethnic","rise":"","length":"","pattern":"Embroidered","sleeve":"","neck_type":"","fit":"","bra_type":"","wiring":"","color_filter":"White","type_filter":"With Blouse","gender":"Women","designed_by":"","article_identifier_type":"","article_identification_value":"","product_dimension":""}
4.
{"color":"Blue","size":"","material":"Georgette","occasion":"Party","rise":"","length":"","pattern":"Embroidered","sleeve":"","neck_type":"","fit":"","bra_type":"","wiring":"","color_filter":"Blue","type_filter":"Semi-Stitched","gender":"Women","designed_by":"","article_identifier_type":"","article_identification_value":"","product_dimension":""}
5.{"color":"Turquoise","size":"","material":"Cotton","occasion":"Party","rise":"","length":"","pattern":"Floral Print","sleeve":"","neck_type":"","fit":"","bra_type":"","wiring":"","color_filter":"Turquoise","type_filter":"Semi-Stitched","gender":"Women","designed_by":"","article_identifier_type":"","article_identification_value":"","product_dimension":""}

A:

Considering the format of this file is semicolon separated CSV, this may be work :
require(jsonlite)

# Importing CSV 
my_data <- read.csv2("data.csv", sep = ";", header = F, stringsAsFactors = F, quote = "") #keep quotes

# Transform JSON into a list
my_data.list <- lapply(my_data$V1, function(x) fromJSON(x))

# Transform into DF
my_data.df <- do.call("rbind", lapply(my_data.list, as.data.frame))

I hope this will help you

