0

I have a csv (file.csv) file which will for the most part be opened using excel, and I want it to act as a data source for an html file. I want to play with the data using vanilla javascript.

The end result I want is as follows:

I want the html file itself to be like a finished good. I don't want the user (generally me) to have to do anything to get data in or anything like that.

Some thing I have considered:

Option 1:

Ajax is not an option because the cors policy will not allow it. Both files are living on the desktop and that is where they have to stay.

Option 2:

An html form or drag/drop functionality using fileReader are not options. I can already do this and the result is not what I want.

Option 3:

Instead of keeping my file as file.csv, I could save it as file.xlsm (a macro-enabled workbook) and write a subroutine in excel-VBA to run when the workbook is closed which would rewrite the html file, updating it with the new data. In this way, there is no real linking; the data would basically be hard-coded into the html file, and overwritten whenever changes are made to the .xlsm file.

Option 4:

I can use a script tag to link to the csv file like so:

src="file:///C:/Users/Username/Desktop/file.csv"

I can see the content of the file in sources, but I don't know how to get it out of there.

Option 5:

I haven't tried using excel-VBA to take my csv file and spit out a json file. I could link to it like in Option 4, and I would know how to access the data.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
dactyrafficle
  • 838
  • 8
  • 18
  • How about writing a trivial web server to locally serve your csv and html from your drive. See : https://stackoverflow.com/questions/3108395/serve-current-directory-from-command-line – JonSG Apr 14 '18 at 19:41
  • I don't think that is an option either. It does work, of course. In fact I just tried using python3 to set up a simple local server and used ajax to get the content into the page. I used xampp too and no issues. The pickle is when I have to read the files in chrome from their actual locations and not thru a server. – dactyrafficle Apr 15 '18 at 02:31
  • Can you help me understand why the "tiny local folder web server" is not going to work? – JonSG Apr 15 '18 at 15:40
  • The computer I'll be working on does not have python or node or ruby etc, and I won't be able to install them. So I won't be able to set up that local folder web server. So it's a pickle. – dactyrafficle Apr 16 '18 at 03:42

0 Answers0