Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# read csv file

StreamReader sr = new StreamReader(FilePath);
importingData = new Account();
string line;
string[] row = new string [5];
while ((line = sr.ReadLine()) != null)
{
    row = line.Split(',');

    importingData.Add(new Transaction
    {
        Date = DateTime.Parse(row[0]),
        Reference = row[1],
        Description = row[2],
        Amount = decimal.Parse(row[3]),
        Category = (Category)Enum.Parse(typeof(Category), row[4])
    });
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: how to know character is a digit or not in c# 
Csharp :: how to select time and date in datetimepicker in c# 
Csharp :: c# get last day of month 
Csharp :: c# load form 
Csharp :: c# function return 
Csharp :: datetime in specific format c# 
Csharp :: integer required asp.net core 
Csharp :: c# remove char from string 
Csharp :: c# sort for loop 
Csharp :: how to deserialize string array in c# 
Csharp :: remove duplicate characters in a string c# 
Csharp :: unity how to destroy child 
Csharp :: hwo to prevent rotation after hitting an object in unity 
Csharp :: detect collision in unity 
Csharp :: c# get the first 4 characters in the list 
Csharp :: join array in c# 
Csharp :: c# string list 
Csharp :: Read a Word Document Using C# 
Csharp :: C# new form 
Csharp :: c# handle single quote inside string 
Csharp :: unity yield return 
Csharp :: emgucv open image c# 
Csharp :: combobox selected name c# 
Csharp :: c# example code 
Csharp :: unity reset random seed 
Csharp :: conditional if statement c# programming 
Csharp :: JsonConvert.DeserializeObject options camelcasing c# .net 
Csharp :: c# datagridview double click on cell 
Csharp :: string to array c# 
Csharp :: c# increment by 1 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =