JavaScript – How to read through a text file…

In this project we are looking at how to read through a text file using JavaScript. We will store a list of pupils in a text file. We are going to read through this list display its content on the webpage, one line at a time.

Step 1:

Using notepad, create a CSV file called ClassList.csv (Instead of using comma we use a pipe | as a separator)

 

Step 2:

Create an HTA application (See our blog post about HTA application).

Step 3:

Add the following code somewhere in the body section of the page:

Step 4:

Add the following Javascript  code in the head section of the page (using as <SCRIPT> tag):

The purpose of this code is to stream through the text file, which means to read it one line at a time.

Your challenge


Use and tweak this code to only display the boys from your class list.

Share Button
Posted in Computer Science, JavaScript

Our Latest Book