Error reading in CSV file

I’m getting an error while reading in a CSV and outputting it to a string.
The file is downloaded from an ftp activity

I think the issue is there is 15000 rows and the memory is having hard time reading it in.

The reason why i want to read it in is that I want to take the top row and make them headers and re write it back into a csv again. This file is downloaded monthly and the bot will have to read in the most up to date file.
Below is my code inside an if statement

Reading such a long data file into a string definitely causes issues.
May be you can simply add a row (headers) at the top of the data table (output of read csv) and export it to CSV.

For example:
The following code is sample c# code for adding a row at the top of the data table.

DataRow newRow = myDataTable.NewRow();
newRow[0] = "ColumnName1";
newRow[1] = "ColumnName2";
myDataTable.Rows.InsertAt(newRow, 0);

Karthik Byggari

1 Like