I have a CSV that contains a list of parts, and different columns showing whether we have pictures of different production steps for each part. Like, first column is part name, second is pattern info, etc.
I can put in an array of the parts we might be working on in a given day.
I want to parse the CSV into an array or whatnot, compare the first column of each line to see if it matches anything on the list of parts for the day, and then print off the entire row of data from the CSV if there's a match.
I have done something like this in Matlab, but because of not having Matlab license for work I am trying to do this in C#, which I am quite new at, so I have the basic idea of what I need to do, but understanding the correct way to do it in C# is something I haven't really grasped yet.
So I've been trying to follow along with one example I found for parsing CSV but I'm just kinda stuck understanding how to modify it for what I want to do.
class Picture{
public string Number;
public string Pattern;
public string Set;
public string Mold;
public string Wash;
public string Core;
public string Close;
public static Picture FromLine (string line)
{
var data = line.Split(',');
return new Picture()
{
Number = data[0],
Pattern = data[1],
Set = data[2],
Mold = data[3],
Wash = data[4],
Core = data[5],
Close =data[6],
};
}
}
class Program
{
static void Main(string[] args)
{
string[] partList = {"cd-6566","CC-0526"};
args = new[]{"ProcessPics.csv"};
var part = ReadPart(args[0]);
Console.WriteLine("Hello World!");
Console.WriteLine("Help");
}
static IList<Picture> ReadPart(string path)
{
var list = new List<Picture>();
foreach (var line in File.ReadLines(path).Skip(1))
{
list.Add(Picture.FromLine(line));
Console.WriteLine("check");
}
return list;
}
}