I used the JavaScript data visualization library D3.js and have distributed my work to customers who view them via web browsers. I am lucky if I can upload a .csv file to an online repository. But sometimes I can’t, and web browsers are not allowed to reference local .csv files for security reasons. But they can reference .js files. Here’s a script to convert a .csv file to a .js file. At a high level, this is the process flow:
- read data.csv
- create a string that is “data = {my JSON objects}”
- write to a file data.js