How to customly parse YAML file with a website or program?

Hello all. I want to parse this csv file and put it into a custom format.

I want to make it so it coverts specific stuff to a JSON.


{"names":"Kusakabe Misuzu","img_url":"null","claims":"null","anime":"11eyes"} 

I want it to be in this format, the img_url and claims don’t have to be there but if theres a site where you can do something like that, please share it.

  - Kusakabe Misuzu

This is how the csv file is formatted, so the ‘11eyes’ goes to the anime section and the ‘Kusakabe Misuzu’ goes to the names section. Sometimes there are multiple characters in a anime thats lists so for every character there is going to be a seperate line on JSON with the character name, I don’t want all the characters to be in one JSON line(Also, if possible I would want to remove the ‘-’).

Is there any website or program that can help me with this?

It looks like this is YAML, not CSV. Here’s a website about that format There’s a list of libraries you can use to parse it. Then it’s just a matter of looping through the entries and outputting several JSON documents, which you might already know how to do.

Any sites you can recommend? I think it could even work if I convert it to JSON then filter it but idk how filter.

Maybe soemthing like this?

If you’re ok with loading the whole CSV natively, you could paste it into a YAML to JSON converter. Just use your search engine, or for your convenience, here’s the first result:

Any other sites?

I want something easier to use, something that can easily filter out data and put that data in a json file.

1 Like

I haven’t really worked with YAML/JSON - what I would do is convert the whole CSV, paste it into a file and then just mutate it like you would a json.

oh. I see but, the file is actually huge so it would take a lot of time.

const yaml = require('./yaml.json')

for (const [key, value] of Object.entries(yaml.uwu)) {
    console.log('{"names":"' + value.characters + '","img_url":"null","claims":"null","anime":"'+ key +'"}')

I just made this quick code which returns:

A bunch of json, I might just continue from here and log it in a txt file. If anyone finds a better way, please share.

Also, If anyone can tell me how I can make it so only 1 character comes per line and not multiple.
I want it so all the other characters come in seperate lines.

You can try \n if you want line breaks…

hahaha, thats not what I mean. I mean, if you look at the photo carefully, there are some lines of JSON with multiple names in the “names” category.

{"names":"Alice Carroll,Mizunashi Akari","img_url":"null","claims":"null","anime":"ARIA"}

This as an example, there are both “Alice Carroll” and “Mizunashi Akari” in the names place. I want so it’s something like this:

{"names":"Mizunashi Akari","img_url":"null","claims":"null","anime":"ARIA"}
{"names":"Alice Carroll","img_url":"null","claims":"null","anime":"ARIA"}

Good progress so far! Here’s some help for the next step. Consider this:

  1. Object.entries(yaml.uwu) is an array
  2. Within the loop you have, value.characters is an array

You’ve shown how to loop over (1). That lets you run a block of code for each entry. The mental leap here is that you can apply the same technique again, on (2). A loop inside a loop. That’ll let you run a block of code for each character.

What exactly do I do, I didn’t understand what you said :laughing: