Я пытаюсь преобразовать CSV-файл с кодами инцидентов с их описаниями в json файл. со следующим кодом.
require 'csv'
require 'json'
csv = File.open('incidentCodes.json').read
CSV.parse(csv).to_json
File.open("incidentCodes.json", "w") do |f|
f.write(csv)
end
Каждый раз, когда я запускаю код, хотя он говорит: «CSV :: MalformedCSVError (Недопустимое цитирование в строке 1)»
Это первые несколько строк моего CSV
111, "Building fire. Excludes confined fires."
112, "Fire in structure, other than in a building. Included are fires on or in piers, quays, or pilings: tunnels or under-
ground connecting structures; bridges, trestles, or overhead elevated structures; transformers, power or utility
vaults or equipment; fences; and tents."
113, "Cooking fire involving the contents of a cooking vessel without fire extension beyond the vessel"
114, "Chimney or flue fire originating in and confined to a chimney or flue. Excludes fires that extend beyond the
chimney."
Я пытался обойти использование CSV.parse с другими методами, которые я видел, но тогда он только записывал «[['identCodes.csv ']]» в файл json. Я очень плохо знаком с ruby, поэтому любая помощь - большая помощь.