Does anyone know how to convert spreadsheets to arrays?

Without the use of an SQL server, i’d like to accomplish the same goal of having an external DB instead of an unchangeable internal DB.
my dad has a co worker programmer that was able to convert a CSV version of a spreadsheet into arrays which then are used to read song names and artists to his computer. He is much too busy to learn unity and explain this to me, so does anyone know?

do you know what csv stands for? in other words, parsing a csv file is stupid easy. Dont over think it, and make it happen

Know what it means, no idea how to do it.

problem is i’m horrible with arrays. if i can get a script that turns a txt or csv file into a 4 column array with 100+ rows, and teach me how to use it to declare vars, i would appreciate it.

This, with commas (for csv).
Then group rows into arrays/lists and then parse int/float.
Pretty simple stuff

how do i do this inside unity? there doesn’t seem to be a split command inside unity so…

also i need to know how to form the array. and how to use arrays. I will have a text document that will read similar to
1, song, artist, year
2, song, artist, year
3, song, artist, year
etc.
i need to be able to get the song/year/artist from any of those. no idea how it is done

Just did this for a data mining project:

  private List<List<String>> data = new List<List<string>>();

 private void ReadCSVFile()
        {
            string line;
            FileStream file = new FileStream("Data_Mining_Student_DataSet_Spring_2013.csv", FileMode.Open);
            StreamReader stream = new StreamReader(file);

            while ((line = stream.ReadLine()) != null)
            {               
                string[] lines = line.Split(';');

                 if (data.Count < 1)
                 {
                     for (int i = 0; i < lines.Length; i++)
                     {
                            data.Add(new List<String>());
                     }
                  }

                    for (int i = 0; i < lines.Length; i++)
                   {
                        data[i].Add(lines[i]);
                   }
                }
            }
        }

The simplest solution is String.Split as BFGames demonstrates. However, be warned that this only works with a subset of CSV. The complete CSV format allows weird things like line breaks, commas and quotations that need to be handled carefully.

There are also libraries out there to help you - e.g. A Fast CSV Reader - CodeProject

Too be honest though, if you’re having difficulty parsing basic CSV I suggest spending more time in C# .Net tutorials, cause that’s what they are there for.

Regular Expressions are your friend :wink: