Search Unity

I want to get data from CSV file to make visualisation

Discussion in 'Scripting' started by Foysal-Ahmed-Emon, Aug 3, 2017.

  1. Foysal-Ahmed-Emon

    Foysal-Ahmed-Emon

    Joined:
    Mar 13, 2016
    Posts:
    8
    Hello, everyone. I want to access a CSV file ( Downloaded and Imported into the asset) or from Google Sheet.
    I want data from exact row and column.

    Like In row 2 there are 100 cells with different data like 2342, 23423, 56343, 2364,6856,34523. I want the value from the cell to generate object to visualize them in Unity3d.

    Can anyone help me with an easy solution?
     
  2. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,532
    You can go the easy route that is not memory efficient by just treating it as one large string, read line for line, split on the comma delimiter of the csv (or other if you use a different delimiter).

    Parse the data accordingly. Converting is simply using the various 'TryParse' methods for the types you want to convert.

    As for what each row/column represents... well that's up to your schema. We don't know that. You know what row 2, column 5 is... do what is necessary with that value.

    ...

    If you want to do this more memory efficiently... well, that gets into a whole other space of things. But honestly, unless your csv file is MASSIVE, you don't really need to concern yourself with that.