今日のレコードのみを選択するなどの基準はほとんどありません。また、レコードに「CA」の文字が含まれている場合は、これら2つの前に基準を追加して、ID番号に基づいて重複するレコードをスキップします。
これが私のコードです
private void btn_convert_Click(object sender, EventArgs e)
{
if ((textBox1.Text == "" )&& (textBox2.Text == ""))
{
MessageBox.Show("Please specify input and output");
}
StringBuilder csvFile = new StringBuilder();
string temp = "";
// string[] file = File.ReadAllLines(@"C:\Users\Program\Desktop\test.txt");
string[] file = File.ReadAllLines(textBox1.Text);
foreach (string line in file)
{
//here I want to add an if condition where only write the unique records based on ID number
if ((line.Contains(DateTime.Now.ToString("MM/dd/yyyy"))) && (line.Contains("\tAU\t"))){
if (line.Contains("\t"))
{
temp = line.Replace("\t", ",");
csvFile.Append(temp + "\r\n");
continue;
}
csvFile.Append(line + "\r\n");
}
}
//File.WriteAllText(@"C:\Users\Program\Desktop\test.csv", csvFile.ToString());
File.WriteAllText((textBox2.Text + "\\test.csv"), csvFile.ToString());
MessageBox.Show("CSV file successfully created at the following location :\n" + textBox2.Text);
}