Improve script code

Factor out loading of CSV data into separate function and parameterize
drawChart function.
PingPong cycles for build B3836