0
我使用Papa Parse将名称,日期和结果的CSV文件转换为JSON对象,但我希望基于名称的对象而不是CSV文件的行。如果这不可能使用Papa Parse,那么我可以使用Angular(或Angular包)中的方法来执行此操作吗?如何使用Papa Parse或Angular根据某个属性合并对象?
我得到以下输出:
[
{
name: 'foo',
date: '11-10-2016',
result: '10'
},
{
name: 'foo',
date: '12-10-2016',
result: '8'
},
{
name: 'bar',
date: '11-10-2016',
result: '1'
},
{
name: 'bar',
date: '15-10-2016',
result: '4'
}
]
但我想这样的输出:
[
{
name: 'foo',
results:
[
{
date: '11-10-2016',
result: '10'
},
{
date: '12-10-2016',
result: '8'
}
]
},
{
name: 'bar',
results:
[
{
date: '11-10-2016',
result: '1'
},
{
date: '15-10-2016',
result: '4'
}
]
}
]
我找到了答案如何与普通的JavaScript here做到这一点,但如果有一个函数来完成它在Papa Parse或Angular中更喜欢使用它。