Simple Text Parsing

We'll be using Processing's loadStrings() function to read a formatted text file either from disk or through a URL from the net.

String[] lines = loadStrings(filename)
or
String[] lines = loadStrings(URL)

And we'll use the split() function to break a line of text into an array of strings,
Suppose you have a file called "fred.txt" inside the data subdirectory of your sketch's directory which contains the 2 lines:

hi, there,
everyone.

calling:
String[] harry = loadStrings("fred.txt");

will give you a harry array of length 2 with:

harry[0] == "hi, there";
harry[1] == "everyone."

You can now use the split() function to separate a string into words...

We're using "words" as strings separated by a single space, ignoring the fact that punctuation will come along with the words.

Let's separate the first line:

String[] parts = split(harry[0]," ");

then we'll end up with a 2 - element parts array, with

parts[0] == "hi,";
parts[1] == "there";

Homework Task:
You'll create a sketch called ParsingText. Once created, you'll have a directory also called "ParsingText".  Create a subdirectory of that directory called "data".

You'll be given a file with a number of lines. Each line with contain a number and a word, separated by a space.  For instance:

1 my,
3 Get
0 Oh
5 work.
2 {NL}
4 to


The special string "{NL}" means a newline occurs in the text.  The number indicates the position in the actual text where the word should appear.
For instance, "Oh" should be the first word and "work." should be the last word.

Your job is to reassemble and print out the correct version of the full text.  The answer for the file above is:

Oh my,
Get to work.
Quick test of your code:
Copy the 6 lines above (starting with "1 my,") into a file called test1.txt and save it in your "data" directory.  Then you can use:

String[] harry = loadStrings("test1.txt")

to load the data...  And then your code should print out the answer above.
Homework task for ParsingText:

loadStrings() can take a URL instead of a filename.  Here's the URL of the file I want you to reassemble correctly:

"http://bert.stuy.edu/pbrooks/fall2021/materials/nextcs-1/flexarray/travel.txt"

Upload your .pde file to the homework server, and copy the reassembled text into the Comments-to-Teacher.