I recently started work on a project that searches a CSV file for duplicate entries and present the user the option to delete one or both entries.
Simple enough it would seem, however I am having an issue with the function that actually parses the CSV file into memory.
Here is the code in question...
using System;
using System.IO;
using Microsoft.VisualBasic.FileIO;
using System.Collections.Generic;
using System.Windows.Forms;
public List<string[]> parseCSV(string path)
{
List<string[]> parsedData = new List<string[]>();
string[] fields;
TextFieldParser parser = null;
string line = parser.ReadLine();
try
{
/*TextFieldParser*/ parser = new TextFieldParser(@"c:\temp\test.csv");
parser.TextFieldType = FieldType.Delimited;
parser.SetDelimiters(",");
while (!parser.EndOfData)
{
fields = parser.ReadFields();
parsedData.Add(fields);
//Did more stuff here with each field.
}
parser.Close();
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
return parsedData;
}
For some reason in VS2017 parseCSV is underlined in red in the function declaration. I can't figure out why this is. I've tried the obvious fixes such as changing the function name from parseCSV to something else but that obviously didn't.
ParseCSVtoParseCsv? If so, ignore it (the latter is the preferred name by most conventions). Are you getting any errors or significant warnings?