Why does Unity fail to read CSV exported from Excel 2010?
This is so frustrating. I have Excel 2010 where we are editing CSV data. But when I save this CSV from Excel, Unity cannot read it as Text Asset! But if I then just load with NotePad+ and save it -- then Unity can read as Text Asset.
I even took the CSV file saved from Excel and used Windows Explorer to Ctrl+C then Ctrl+V (copy/paste in place) -- and it created a copy just fine -- and Unity could read the COPIED file just fine. But not the original file.
We use SVN, it shows zero differences in the file for check-in. Yet somehow Unity seems to care how the file was last saved -- Text Editor (works fine), but Excel 2010 fails entirely.
This is not acceptable. It's like Unity is going out-of-its-way to do something that is very pointlessly frustrating, and even seems impossible.
Why would/should Unity care which program saved it? And why then would a Windows Explorer Copy/Paste then create a file that Unity can read just fine?
Yeesh.
I don't have Excel 2010, but 2016. I've been able to read CSV files created with excel in Unity. I just tested that created file reads into Unity as TextAsset, I'm able to debug.Log the contents.
CSV is just a text file with different file extension -maybe there are some settings for text encoding - at least in 2016, the format to save csv is utf-8 in save dialog.
Are you sure Excel
is not running when you try to read the file with Unity? You may have an access issue (Unity is trying to read a file locked by Excel)
Do you get any error in the console?
@Hellium - I just noticed this question was sort of necro'ed by this guy selling his asset (he has spammed his asset as solution to several csv questions. OP asked his question weeks ago...
Answer by MyUnitydream · Sep 12, 2018 at 05:12 AM
you can use Uni-Excel Package for Read, Write, and edit excel files
Answer by maximilianahead · Oct 22, 2019 at 01:47 PM
Because you are opening csv by EXCEL so close it and free.
However, you can read open files by following.
using (FileStream fs = new FileStream("test.csv", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (TextReader sr = new StreamReader(fs))
{
content = sr.ReadToEnd();
}