-1

A little context: I work in a totally different department from web development but my current project needs me to make a webpage. I'm absolutely new to web development and have only a basic idea of HTML and CSS.

What needs to be done?: I made a webpage and I need to place a drop-down filter in the webpage which should be populated by the data from only one column in a .csv file that's stored locally in the PC. The column will have duplicate records but I need only distinct records to be shown in the drop-down filter.

A little research led me to realizing that I need to create an API using node.js. I have no exposure to node.js, let alone creating APIs. I'm hoping someone must have done this before and I'd be grateful if someone could tell me where and how do I get started on how to do this.

Modus Tollens
  • 5,083
  • 3
  • 38
  • 46
learningsql
  • 19
  • 1
  • 8
  • Privacy reasons – learningsql Jun 04 '20 at 07:10
  • I rolled back your post. Please don't vandalize your post, people took effort to answer it. See https://meta.stackexchange.com/q/153118/686592 – Modus Tollens Jun 04 '20 at 07:13
  • "Privacy reasons" doesn't really apply - anyone can see whatever was removed by looking at the edit history. If you posted something you shouldn't have, you'll need to flag your question for removal by a mod. – Tieson T. Jun 04 '20 at 07:19

1 Answers1

1

Node.js is a good way to solve this. Generally, it might be good to start off by reading an introduction.

Actually, most of the things you'll need might already be answered on Stack Overflow, so here's just a quick outline:

First off all, you will need to open up your csv using the included file-system module.

Once you've got the csv as an array, turn that one column into an array:

csv.split('\n').map(v => v[ columnNumber ]);

Then you dedupe that array.

The last thing is to dynamically generate the dropdown, which is quite straight-forward - just use some for-loop, but figure that out yourself. To include it into the frontend, for example put the whole frontend's html into an external file and include a placeholder (like {dropdown}), fetch it with fs, an then replace the placeholder:

webAppString.replace('{dropdown}', generatedDropdownHtml);
Örom Loidl
  • 366
  • 2
  • 12