Reading from .CSV works fine on windows editor, and no data on device (Android)

Hello,

I have several excel files which I’ve exported to .csv and reading the data with FileStream and saving to custom classes … everything working perfeclty when I run on the editor.

string fileName = "/MyData/" + packages *+ ".csv";*

streamReader = new StreamReader(File.OpenRead(Application.dataPath + fileName ));
since I have several .csv files I have the names in a List of strings.
(naming and spelling are correct since data is displayed accurately on the editor).
I did an android build, and a blank screen, data is not retrieved .
However a crash might result the same, but I have no errors/null values when runing on the editor.
So …
Is it related to the path ? Application.dataPath problems on devices?
or something related to the file format?
or if anyone has a different suggestion.
Thanks for your time :slight_smile:

If you need to include this file to the build you have the only one way: place it to the Resources folder and use Resources.Load. You can use *.bytes extension for binary data. For ex.:

using (BinaryReader reader = new BinaryReader(new MemoryStream((Resources.Load(filename) as TextAsset).bytes)))
{
    // Read your data here
}

Yes, you need to use a different path.
From the documentation:
//Data (this folder is read only, use Application.persistentDataPath to save data).

The docs say this is for iOS but the same limitation applies on Android IIRC. The standard data path is readonly. If you don’t intend to edit the file at runtime, you are better off putting it in Resources and accessing it from there using Resources.Load(). Info in the docs is HERE