| name | Load and Validate Stock Data for Ticker Field Presence |
| description | Load CSV data and verify all stock entries contain the required `ticker` field with non-empty string values before using in selection matching logic |
d3.csv('/root/output/data/stock-descriptions.csv').then(function(data) {
data.forEach((d, index) => {
if (!d.ticker || d.ticker.trim() === '') {
console.warn(`Row ${index} is missing ticker field:`, d);
}
d.ticker = d.ticker.trim();
d.name = d.name.trim();
d.sector = d.sector.trim();
if (d.marketCap === '' || d.marketCap === null) {
d.marketCap = null;
} else {
d.marketCap = parseFloat(d.marketCap);
}
});
console.log('Loaded stock data:', data);
const etfCount = data.filter(d => isETF(d)).length;
const nonETFCount = data.length - etfCount;
console.log(`Total stocks: ${data.length}, ETFs: ${etfCount}, Non-ETF: ${nonETFCount}`);
initializeVisualization(data);
});
Validation checklist:
- Confirm all 50 stocks have non-empty ticker values
- Trim whitespace from ticker, name, and sector fields
- Properly parse marketCap as number or null
- Log data to browser console to verify structure
- Check that ticker field matches between bubbles and table rows during matching