Skip to content

Instantly share code, notes, and snippets.

@AABoyles
Created April 20, 2020 03:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AABoyles/f55bc9c3f8c60fff7a58f523d403ef34 to your computer and use it in GitHub Desktop.
Save AABoyles/f55bc9c3f8c60fff7a58f523d403ef34 to your computer and use it in GitHub Desktop.
// Go To https://healthweather.us/ and run this in your Browser's Developer Console.
async function loadScript(url){
let script = document.createElement("script");
script.type = "text/javascript";
await fetch(url).then(r => r.text().then(s => script.innerHTML = s));
document.body.appendChild(script);
}
loadScript("https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.1.0/papaparse.min.js")
loadScript("https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.8/FileSaver.min.js");
states = ['AL','AZ','AR','CA','CO','CT','DE','DC','FL','GA','ID','IL','IN','IA','KS','KY','LA','ME','MD','MA','MI','MN','MS','MO','MT','NE','NV','NH','NJ','NM','NY','NC','ND','OH','OK','OR','PA','RI','SC','SD','TN','TX','UT','VT','VA','WA','WV','WI','WY'];
let csv = 'region_id,region_name,state,date,doy,observed_ili,atypical_ili,anomaly_diff,forecast_expected,forecast_lower,forecast_upper';
let promises = [];
states.forEach(usps => {
promises.push(fetch(`https://static.kinsahealth.com/${usps}_data.json`).then(r => r.json().then(d => {
csv += '\n'+Papa.unparse(d.data);
})));
});
Promise.all(promises).then(() => saveAs(new Blob([csv], {type: "text/csv;charset=utf-8"}), 'Kinsa_data.csv'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment