1

I have a .csv, file unfortunately one of the columns contains a dictionary that has commas in it , for example:

{"name": "Umbulharjo", "type": "Kecamatan", "level": "3", "region1": "Yogyakarta", "region2": "Yogyakarta", "region3": "Umbulharjo", "postcode": "55161"}

How can i put a " before every { and after every } in R? then i can set " as quote when i am using read.csv or read.csv2 or read.table

2 Answers2

1

Your data looks to be JSON-ish. If you're doing a lot of JSON stuff, I suggest using a library that understands JSON.

Community
  • 1
  • 1
Bob Salmon
  • 411
  • 4
  • 10
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\"} "
Sotos
  • 51,121
  • 6
  • 32
  • 66