I am attempting to open a text file that essentially has csv data in it. Sometimes it will have quotes and sometimes not. It will not have header values (not required either). It will have 1 or more rows as well.
Is there a built in Library to parse text as CSV and return a List?
2 Likes
I figured there might be a built in utility. Ice.Lib.SharedUtilities.ImportExport.dll appears to be what I need, but… Not sure I can get it into my customization. Thanks. I will try it out.
Yes, there is an epicor lib for it. Dont know it off the top of my head
Update: The one you referenced is right. To use it, just use the Assembly Reference Manager and import it into your customization. Then add a using Ice.Lib.SharedUtilities.
Maybe you can do: (untested)
using(var reader = new CsvReader(filename))
{
reader.Seperator = '~';
do
{
string line = reader.GetCSVLine();
var myData = new ArrayList();
ParseCSVFields(myData, line);
}
while (!string.IsNullOrEmpty(line))
}
//myData is now an array of your decoded fields on the line
1 Like
I can’t add it to the Assembly Reference. It selects and saves, but never shows in the Custom list.
It will show up under custom assemblies.
also i tested this to compile at least:
using Ice.Lib.SharedUtilities.ImportExport;
string filename;
using(var reader = new CsvReader(filename))
{
reader.Separator = '~';
string[] line;
do
{
line = reader.GetCSVLine();
//get your data from the line items - line[0], etc
}
while (line.Count() > 0);
}
1 Like