- Home /
Can I download and then read a CSV all at runtime? If so, how?
I want to download a CSV from an online source from inside my app and then read it all at run-time.
It looks like I cant put the CSV in resources as this is only for pre-compiled stuff (I think). So how would I go about doing it?
Cheers
Answer by Salanyel · Jul 27, 2016 at 02:03 PM
You can use two different ways :
1- You're online, don't hesitate to use a webservice and read the data from it. (https://docs.unity3d.com/ScriptReference/WWW.html)
2- If you downloa d the file, you can use the following :
Application.dataPath
(https://docs.unity3d.com/ScriptReference/Application-dataPath.html) or persistantDataPath in order to dynamically load a file by using the common C# function.
Cool. I'm still not sure exactly how I need to download it though. As a www.text file and then somehow parse the data from there?
It's a possibility.
Or, a webservice in php can just send you the entire content of your csv. With the method text (https://docs.unity3d.com/ScriptReference/WWW-text.html):
Not sure exactlty how to do that. At the moment I have downloaded my CSV as www.text but when I go the print (all) the text in the editor it just hangs because the data is so big I presume (220mb). Is there a way I can easily parse this www.text or somehow save it to disk as an actual csv? Then I think there maybe a plugin I can use to manipulate it...maybe