So, I have a static data export file which is only available as a .YAML file. It's pretty large, so here is a piece of the code inside for you to understand how does it look like:
2047:
activities:
copying:
time: 720
invention:
materials:
- quantity: 2
typeID: 20416
- quantity: 2
typeID: 20415
products:
- probability: 0.34
quantity: 10
typeID: 2049
skills:
- level: 1
typeID: 11529
- level: 1
typeID: 11442
- level: 1
typeID: 23121
time: 13800
manufacturing:
materials:
- quantity: 1062
typeID: 34
- quantity: 2
typeID: 35
- quantity: 53
typeID: 36
products:
- quantity: 1
typeID: 2046
skills:
- level: 1
typeID: 3380
time: 900
research_material:
time: 315
research_time:
time: 315
blueprintTypeID: 2047
maxProductionLimit: 200
26407:
activities:
copying:
materials:
- quantity: 10
typeID: 3812
skills:
- level: 1
typeID: 26260
time: 36000
manufacturing:
materials:
- quantity: 24
typeID: 25617
- quantity: 35
typeID: 25619
- quantity: 1
typeID: 11486
- quantity: 27
typeID: 25607
products:
- quantity: 1
typeID: 26406
skills:
- level: 5
typeID: 3380
- level: 1
typeID: 11449
- level: 1
typeID: 11452
- level: 1
typeID: 26260
time: 45000
research_material:
skills:
- level: 5
typeID: 3409
- level: 1
typeID: 26260
time: 15750
research_time:
skills:
- level: 5
typeID: 3403
- level: 1
typeID: 26260
time: 15750
blueprintTypeID: 26407
maxProductionLimit: 1
31705:
activities:
copying:
time: 1200
invention:
materials:
- quantity: 1
typeID: 20424
- quantity: 1
typeID: 20423
products:
- probability: 0.34
quantity: 1
typeID: 31711
skills:
- level: 1
typeID: 11451
- level: 1
typeID: 11452
- level: 1
typeID: 21791
time: 7200
manufacturing:
materials:
- quantity: 2
typeID: 25593
- quantity: 4
typeID: 25601
- quantity: 3
typeID: 25599
products:
- quantity: 1
typeID: 31704
skills:
- level: 1
typeID: 3380
- level: 1
typeID: 26257
time: 1500
research_material:
skills:
- level: 1
typeID: 3409
- level: 1
typeID: 26257
time: 525
research_time:
skills:
- level: 1
typeID: 3403
- level: 1
typeID: 26257
time: 525
blueprintTypeID: 31705
maxProductionLimit: 100
I want to transform that data into a Google Sheets table, however I faced a problem: I can't use the .YAML file using the "import" function inside the Google Sheets, since .YAML files are not supported.
I tried 20 different online converters and also tried to convert the .YAML to .CSV, .HTML and other file types what are eligible for Google Sheets import, but it either didn't work with such a large file or the resulting table was missing like half of the content with incorrect data placement among raws and columns.
For now, I don't even think about formatting the data and how do I want the resulting table to look like. I only want to somehow transform that .YAML into a properly working Google Sheet table which is not missing any data.
Please, advise me how would you solve that issue.
P.S.: Also, please keep in your mind that I am absolute 0 to programming, the only thing I can do is copy-paste the code into Google Scripts attached to the Google Sheet and then invoke the containing function. If your solution works separately from GSheets and GScripts environment, please, also advise the actual way how a lamer like me can use it.
CodePudding user response:
Convert YAML to JSON
This is the data converted to JSON.
{
"2047": {
"activities": {
"copying": {
"time": 720
},
"invention": {
"materials": [
{
"quantity": 2,
"typeID": 20416
},
{
"quantity": 2,
"typeID": 20415
}
],
"products": [
{
"probability": 0.34,
"quantity": 10,
"typeID": 2049
}
],
"skills": [
{
"level": 1,
"typeID": 11529
},
{
"level": 1,
"typeID": 11442
},
{
"level": 1,
"typeID": 23121
}
],
"time": 13800
},
"manufacturing": {
"materials": [
{
"quantity": 1062,
"typeID": 34
},
{
"quantity": 2,
"typeID": 35
},
{
"quantity": 53,
"typeID": 36
}
],
"products": [
{
"quantity": 1,
"typeID": 2046
}
],
"skills": [
{
"level": 1,
"typeID": 3380
}
],
"time": 900
},
"research_material": {
"time": 315
},
"research_time": {
"time": 315
}
},
"blueprintTypeID": 2047,
"maxProductionLimit": 200
},
"26407": {
"activities": {
"copying": {
"materials": [
{
"quantity": 10,
"typeID": 3812
}
],
"skills": [
{
"level": 1,
"typeID": 26260
}
],
"time": 36000
},
"manufacturing": {
"materials": [
{
"quantity": 24,
"typeID": 25617
},
{
"quantity": 35,
"typeID": 25619
},
{
"quantity": 1,
"typeID": 11486
},
{
"quantity": 27,
"typeID": 25607
}
],
"products": [
{
"quantity": 1,
"typeID": 26406
}
],
"skills": [
{
"level": 5,
"typeID": 3380
},
{
"level": 1,
"typeID": 11449
},
{
"level": 1,
"typeID": 11452
},
{
"level": 1,
"typeID": 26260
}
],
"time": 45000
},
"research_material": {
"skills": [
{
"level": 5,
"typeID": 3409
},
{
"level": 1,
"typeID": 26260
}
],
"time": 15750
},
"research_time": {
"skills": [
{
"level": 5,
"typeID": 3403
},
{
"level": 1,
"typeID": 26260
}
],
"time": 15750
}
},
"blueprintTypeID": 26407,
"maxProductionLimit": 1
},
"31705": {
"activities": {
"copying": {
"time": 1200
},
"invention": {
"materials": [
{
"quantity": 1,
"typeID": 20424
},
{
"quantity": 1,
"typeID": 20423
}
],
"products": [
{
"probability": 0.34,
"quantity": 1,
"typeID": 31711
}
],
"skills": [
{
"level": 1,
"typeID": 11451
},
{
"level": 1,
"typeID": 11452
},
{
"level": 1,
"typeID": 21791
}
],
"time": 7200
},
"manufacturing": {
"materials": [
{
"quantity": 2,
"typeID": 25593
},
{
"quantity": 4,
"typeID": 25601
},
{
"quantity": 3,
"typeID": 25599
}
],
"products": [
{
"quantity": 1,
"typeID": 31704
}
],
"skills": [
{
"level": 1,
"typeID": 3380
},
{
"level": 1,
"typeID": 26257
}
],
"time": 1500
},
"research_material": {
"skills": [
{
"level": 1,
"typeID": 3409
},
{
"level": 1,
"typeID": 26257
}
],
"time": 525
},
"research_time": {
"skills": [
{
"level": 1,
"typeID": 3403
},
{
"level": 1,
"typeID": 26257
}
],
"time": 525
}
},
"blueprintTypeID": 31705,
"maxProductionLimit": 100
}
}