Update csv2json.js

Wrapped everything in a single function and assigned it to a generic CSV variable.