How to load CSV files from webplayer

Yes, I realize that I could simply make the extension of my CSV file .TXT and use TextAsset to load it, however I do not want to do this. The CSV extension must remain as-is.

Basically I have a CSV file that I need to load and get the full text from. I can't use TextAsset because it's not a TXT file, and I've tried using Resources.Load(), however I'm not sure what type to cast it to.

How can I load a CSV file and access its contents? I tried using System.IO.StreamReader, and while this works in the editor, it does not work in the web player.

To quote from: Best way to output data from Unity: "...not available in the webplayer for security reasons." The extension doesn't matter, the Browser simply isn't allowed to read or write to the local machine. You could either make your program a stand-alone executable, or put the datafile on the Server.

Update: to demonstrate this is an issue with the web-player, try building a standalone executable. Your System.IO.StreamReader code should read the file with no problem (assuming no bugs). Does that solve your problem?

If your answer is "no, I want the Browser to read the file", then sorry, it won't work.

Depending on the type of data, you might be able to use PlayerPrefs. Also see Does Unity have cookies? Since you appear to want a .csv file, probably not, but I thought I'd mention them.

Unity Web player does not allow file manipulation(read or write). The best way to do this is using WWW in Unity to retrieve information from the file via PHP. Since CSV basically contains comma separated valued text, they can be passed echoed out as it is and on the unity side they can be split in an array using ‘,’ (comma) delimiter. Let me know if you need more information or a sample code.

I think the answers miss the point.

You can actually “load” a .txt file from the webplayer when you refer to it from a TextAsset or put the file into a Resources folder. That’s possible because in this case it’s not actually loaded in runtime from the hard drive, but included in the executable - just like textures, sounds or whatever other resources you use in your program.

The asker wants to know (and so do I) if there is a way to do a similar thing with a .csv file, without changing the extension. It seems not to be possible, but maybe I’m wrong?