我有一个.csv文件,遗憾的是其中一列包含一个包含逗号的字典,例如:
{"name": "Umbulharjo", "type": "Kecamatan", "level": "3", "region1": "Yogyakarta", "region2": "Yogyakarta", "region3": "Umbulharjo", "postcode": "55161"}
我怎样才能放一个"在R之前的每个{和之后}之前?然后我可以设置"当我使用read.csv或read.csv2或read.table
时作为引用答案 0 :(得分:1)
您的数据看起来像是JSON-ish。如果你正在做很多JSON的事情,我建议使用library that understands JSON。
答案 1 :(得分:0)
paste('{"name": "Umbulharjo", "type": "Kecamatan", "level": "3", "region1": "Yogyakarta", "region2": "Yogyakarta", "region3": "Umbulharjo", "postcode": "55161"}', '')
#[1] "{\"name\": \"Umbulharjo\", \"type\": \"Kecamatan\", \"level\": \"3\", \"region1\": \"Yogyakarta\", \"region2\": \"Yogyakarta\", \"region3\": \"Umbulharjo\", \"postcode\": \"55161\"} "