Skip to main content

Posts

Showing posts from February, 2015

How to write data to CSV file in UNITY

Hi Guys, if any one is facing problem to save data in csv file can use this solution. If you have any questions, you can ask me through comments.

Things to remember :
Never ever add any commas to your data otherwise, cells will get messed up completely. 


Results :


Here is the code

usingUnityEngine;
usingSystem.Collections;
usingSystem.Collections.Generic;
usingSystem.Text;
usingSystem.IO;
usingSystem;

publicclassCsvReadWrite : MonoBehaviour {

privateList<string[]> rowData = newList<string[]>();


//Usethisforinitialization
voidStart () {
Save();
    }

voidSave(){

//CreatingFirstrowoftitlesmanually..
string[] rowDataTemp = newstring[3];
rowDataTemp[0] = "Name";
rowDataTemp[1] = "ID";
rowDataTemp[2] = "Income";
rowData.Add(rowDataTemp);

//Youcanaddupthevalues