简体   繁体   中英

How to convert plain set of data from the file into json format

I have some plain machine learnig data set in separate lines like this:

vhigh,vhigh,2,4,small,low,unacc

vhigh,vhigh,2,4,small,med,unacc

vhigh,vhigh,3,more,med,low,unacc

... 1700 more lines like above

I want to convert data into structure like this:

[
  {
    "buying": "vhigh",
    "maint": "vhigh",
    "doors": "2",
    "persons": "2",
    "lug_boot": "small",
    "safety": "low",
    "evaluation": "unacc"
  },
  {
    "buying": "vhigh",
    "maint": "vhigh",
    "doors": "2",
    "persons": "2",
    "lug_boot": "small",
    "safety": "med",
    "evaluation": "unacc"
  },
...

]

and save converted data into new file.json

#edit : Node.js runtime

I found the answer. Thank you for targeting the csv. It was enough to use the conversion tool here: https://csvjson.com/csv2json

After conversion: csv转换器

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM