parse text file into multiple arrays.

I have a text file with headings and lists of words. What’s the best way to format the text files and parse the files so that each heading is an array and the list of words is the content of that array?

2 Answers

2

Use CSV (comma separated values) at TSV (tab sea vales).
Read file line by line, or all into all into a string then Split on newline.
Split each line on comma (or tab) and it creates an array for that line.
so if you want at columns sorted into arrays, create empty column arrays at start,
then sort the values split out of each line into those arrays (With Add or Append)

Here’s what I have so far. My problem is I will have an unknown number of arrays in each text file. How do I account for that?

function GetArrays ()
{

    var myArray = new Array();
    var inputList = inputTxt.text.Split(","[0]);
	for (var j = 0; j < inputList.Length; j++) 
	{
	    if (inputList[j] == "

"[0])
{
//make new array
}
else
{
myArray.Push(inputList[j]);
Debug.Log(inputList[j]);
}

	}
}

oops, didnt mean to answer

figured it out - I created an array and added a new array to this array at each new ling.

Hi mythicke, I have the same question about this issue but I have a lot less coding experience, I was wondering if it would be possible to get the code solution that you came up with. I am having a hard time to finding an answer to this topic.