0

I have a .csv list with names separated with semicolons: John Smith;Ola Nordmann; etc, and I was wondering how I can read the file and then print out the names like this:

<select>
  <option> John Smith
  <option> Ola Nordmann
  <option> etc
<\select>

It’s a local csv file and I have to use vanilla JavaScript.

My thought was that I could use a for-loop and somehow count the semicolons to determine the for-loops length, but I don’t really know how to do that. Nor do I know how get the data “out” of the file and “into” the option list.

Burhan Ali
  • 2,258
  • 1
  • 28
  • 38
  • Use can use `split(';')` on the string to get an array of names. As to how to read a file try this https://stackoverflow.com/a/12372727 if you if will supplying the file from browser – Vinay Jan 26 '20 at 03:14
  • I assume you mean "csv", as in "character-separated value"? CVS is either a pharmacy or a source-control system, depending on context. – Tieson T. Jan 26 '20 at 03:27
  • @Viney what if it's from a local file? – SirGodLordKing Jan 26 '20 at 14:53

0 Answers0