Read CSV for DataGrid

There is a CSV file which encoded in Shift-JIS(cp932).

Even though I tried to find API or doc, whether there is any way to read and convert it into UTF-8 properly.

Is there any API like this in syncfusion component itself?

or

using (var reader = new StreamReader(filePath, Encoding.GetEncoding("shift-jis"))) though I didn't try this code line, but I am not sure if this is the right thing or not, or I would like to know is there any way I can implement this working with syncfusion API itself.


Than you so much.


1 Reply

PK Priyanka Karthikeyan Syncfusion Team April 5, 2024 11:44 AM UTC

Hi LEE,

Greetings from Syncfusion Support.

You can utilize the following method to read a CSV file and convert it to UTF-8:

var stream = singleFile.OpenReadStream();
var csv = new List<string[]>();
MemoryStream ms = new MemoryStream();
await stream.CopyToAsync(ms);
stream.Close();
var outputFileString = System.Text.Encoding.UTF8.GetString(ms.ToArray());


For more information please refer the below common blogs

https://www.c-sharpcorner.com/article/read-csv-file-from-blazor-web-assembly/


Regards,

Priyanka K


Loader.
Up arrow icon