// usage: node sport.js file.table.txt SPORTHEADER (girls section = second occurrence after "GIRLS PARTICIPATION") const fs=require('fs');const [,,file,sport]=process.argv; const L=fs.readFileSync(file,'latin1').split(/\r?\n/); let gi=L.findIndex(l=>/GIRLS PARTICIPATION/.test(l)); let h=-1;for(let i=gi;i{const c=(p[0].start+p[1].end)/2;const d=Math.abs(c-scenter);if(d{let bi=0,bd=1e9;cols.forEach((c,ci)=>{const d=Math.abs((tk.s+tk.e)/2-(c.start+c.end)/2);if(da[0]===pc).map(a=>a[1]);out[st.replace(/^Dist\. of Columbia$/,'District of Columbia')]=v.length?v[0]:0;} const sum=Object.values(out).reduce((a,b)=>a+b,0);console.error(file,sport,'states',Object.keys(out).length,'sum',sum); console.log(JSON.stringify(out));