如何创建看起来像这个JSON文件的CSV文件
我基本上想为NFT游戏(Axie Infinity)更新多个学者。它需要一个看起来像这样的JSON文件:
{
"name": "Scholar 1",
"ronin": "ronin:<account_s1_address>",
"splits": [
{
"persona": "Manager",
"percentage": 44,
"ronin": "ronin:<manager_address>"
},
{
"persona": "Scholar",
"percentage": 40,
"ronin": "ronin:<scholar_1_address>"
},
{
"persona": "Other Person",
"percentage": 6,
"ronin": "ronin:<other_person_address>"
},
{
"persona": "Trainer",
"percentage": 10,
"ronin": "ronin:<trainer_address>"
}
]
}
但是,由于有多个学者/播放器,我想知道是否有任何CSV文件上的某些内容,如果我使用JSON工具将其转换或导入它,它将看起来像上面的JSON?
您的帮助非常感谢..谢谢!
PS:
第一行:
"name": "Scholar 1",
"ronin": "ronin:<account_s1_address>",
"splits":
需要重复,因为再次有多个学者,即学者1,Scholar 2,Scholar 3 ...
I am basically wanting to update multiple scholars for an NFT game (axie infinity). It requires a JSON file that looks like this:
{
"name": "Scholar 1",
"ronin": "ronin:<account_s1_address>",
"splits": [
{
"persona": "Manager",
"percentage": 44,
"ronin": "ronin:<manager_address>"
},
{
"persona": "Scholar",
"percentage": 40,
"ronin": "ronin:<scholar_1_address>"
},
{
"persona": "Other Person",
"percentage": 6,
"ronin": "ronin:<other_person_address>"
},
{
"persona": "Trainer",
"percentage": 10,
"ronin": "ronin:<trainer_address>"
}
]
}
But since there are multiple scholars/players, I wanted to know if there was anyway to format something on a CSV file that if I convert or import it using a JSON tool it will look like like the JSON above?
Your help is much appreciated.. Thank you!
PS:
The first lines:
"name": "Scholar 1",
"ronin": "ronin:<account_s1_address>",
"splits":
Would need to be repeated since again there are multiple scholars, i.e. Scholar 1, Scholar 2, Scholar 3...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
CSV文件结构是列基库,如果Axie Infinity需要JSON文件,则可以通过Excel或Google Sheet创建CSV文件,然后转换为JSON。
也有类似的答案可以将CSV转换为JSON
CSV file structure is column-base, if Axie infinity require JSON file, you can create a CSV file by Excel or Google sheet and convert to JSON.
there is a similar answer to convert CSV to JSON
starting from this CSV that has this structure
您可以运行此 miller 命令
有
一些注释:
reshape -r“ (p | s)“ -ok,v
,以将输入从宽到长;put'$ k =“ splits”。“。”。$ {id_persona}。“。$ k'
,创建我将用作字段名称的值(splits.1) 。
id_persona
;reshape -sk,v
,从长时间转换。而不是使用它来创建最终的JSON输出
starting from this CSV that has this structure
you can run this Miller command
to have
Some notes:
reshape -r "^(p|s)" -o k,v
, to transform the input from wide to long;put '$k="splits".".".${id_persona}.".".$k'
, to create values that I will use as field names (splits.1.persona,splits.1.percentage,splits.1.split_ronin,splits.2.persona,splits.2.percentage, ....
cut -x -f id_persona
, to remove the fieldid_persona
;reshape -s k,v
, to transform all from long to wide.The real goal is to build, starting from that input, this kind of CSV
and than use it to create the final JSON output