0

Reading 3 sets of files recursively by date to load into one array of arrays of objects to send to a graphing function

This worked previously when I didn't have a promise all and I was just pushing into one spot of Loaded_Data:

i.e.:

Loaded_Data = [];

 d3.tsv("location.txt").then( { data => data.forEach( d => {Loaded_data.push(d);}) } );

works fine.

When I try to change "Loaded_Data=[];" to:

Loaded_Data = [[],[],[]];  //empty the array from previous load

Promise.all([d3.tsv("location.txt"), d3.tsv("location2.txt"), d3.tsv("location3.txt")])
.then( data => {
    data[0].forEach( d =>  { Loaded_Data[0].push(d);})
    data[1].forEach( d =>  { Loaded_Data[1].push(d);})
    data[2].forEach( d =>  { Loaded_Data[2].push(d);})
});

when i console.log(Loaded_Data) i expect:

[[{object1a},{o2a},{o3a},{...}],[{object1b},{o2b},o3b},{...}],[{object1c},{o2c},{o3c}]]

But I get the error: "Loaded_Data[0].push(d) is not a function"

Isn't this the correct way to access my array of arrays of objects?

HAZRD
  • 63
  • 5

1 Answers1

-2

Looks like dumb me going from one instance to the recursive forgot to include an iterator and i was getting essentially a ... wait for it ... STACK OVERFLOW!!! .

I was explaining my code to my rubber ducky and found it. what a waste of 2 hours. facepalm

HAZRD
  • 63
  • 5