After finding inspiration in this thread on storing CSV files in separate arrays, I successfully implemented it. Now, I am hoping to expand my setup by incorporating 8 additional arrays, each containing the contents of CSV files.
My main challenge now is how to combine all these arrays into a single array of objects. This is crucial for the next phase of utilizing these arrays effectively. The code snippet I have currently is displayed below, but I am uncertain if it is correct:
Any assistance or guidance on this matter would be greatly appreciated.
var dataCSV;
var dataCSV2;
var collection = {dataCSV, dataCSV2};
d3.csv("data/csv1.csv", function(data) {
data.forEach(function(d) {
d.word = d.word;
d.frequency = +d.frequency;
})
dataCSV = data;
console.log(dataCSV);
});
d3.csv("data/csv2.csv", function(data) {
data.forEach(function(d) {
d.word = d.word;
d.frequency = +d.frequency;
})
dataCSV2 = data;
console.log(dataCSV2);
});
function merge(data1, data2) {
collection = {data1, data2};
console.log(collection);
}
merge(dataCSV, dataCSV2);
The desired output for the 'collection' should ideally be structured as follows:
collection {
dataCSV {
word: ..., frequency: ...,
word: ..., frequency: ...
},
dataCSV2 {
word: ..., frequency: ...,
word: ..., frequency: ...
}
}