- Home /
Question by
benfattino · Jul 12, 2015 at 06:44 PM ·
wwwparsecsv
Parsing a CSV load from server
I (urgent) need to parse cvs load from server. I try with this, but there is no way to parse. Script load file successfully, but won't parse.
using UnityEngine;
using System.Collections;
using System.Linq;
using System.Text;
using System.IO;
public class CSVReaderWWW : MonoBehaviour {
public string url;
public string csvText;
public string[,] grid;
public string[] lines;
public string test;
int i;
int j;
// Use this for initialization
void Awake () {
StartCoroutine (LoadCSV());
}
void Start (){
lines = ParsingCSV (csvText);
}
// Update is called once per frame
void Update () {
}
IEnumerator LoadCSV(){
WWW www = new WWW (url);
yield return www;
csvText = www.text;
}
public string[] ParsingCSV (string csvTextParsing){
string[] line = csvTextParsing.Split ("\n" [0]);
return line;
}
}
Please somebody help me! S.
Comment
Answer by benfattino · Jul 12, 2015 at 08:02 PM
Ok. Found this work:
IEnumerator LoadCSV(){
WWW www = new WWW (url);
yield return www;
csvText = www.text;
lines = ParsingCSV (csvText);` <-- moving this from outside
}
but when execute give me this error:
NullReferenceException: Object reference not set to an instance of an object CSVReaderWeb.Update () (at Assets/CSVReaderWeb.cs:54)