Executing the code below throws Error: Cannot create a string longer than 0x3fffffe7 characters
. My file contains only 2 arrays and composed
, the whole file contains 1,3GB. I wanted to combine them by id by using something like the code below to map through the arrayMain and return each object combined with the object from arrayItems with the same id and then restructure that object to throw out the id. But I think I am bumping up against a system limit. I am fairly new to working with large data files so any help is appreciated.
const composed = arrayMain.map((d) => {
return {
...d,
data: arrayItems.filter(({ ID }) => d.ID === ID).map(({notNeeded, ...needed}) => needed),
};
});
If anyone is wondering how my data is structured
const arrayMain = [
{
ID: 30574062,
number: 28234702,
place: London,
},
{
ID: 30574063,
number: 45232502,
place: Paris,
},
...
];
const arrayItems = [
{
"ID": 30574062,
"anotherNumber": "52,3",
"color": "red"
},
{
"ID": 30574062,
"anotherNumber": "13",
"color": "yellow"
},
{
"ID": 30574063,
"anotherNumber": "60,6",
"color": "blue"
},
...
]
//expected result
[
{
ID: 30574062,
number: 28234702,
place: London,
data: [
{
"anotherNumber": "52,3",
"color": "red"
},
{
"anotherNumber": "13",
"color": "yellow"
}
]
},
{
ID: 30574063,
number: 45232502,
place: Paris,
data: [
{
"anotherNumber": "60,6",
"color": "blue"
},
]
},
...
]