I have this code to combine 2 different csv files.
try
{
var jobStartLine = File.OpenText(PackAuftrag).ReadLine();
var comparisonField = jobStartLine.Split(';')[4];
foreach (var line in File.ReadAllLines(BoxData))
{
var fields = line.Split(new char[] {';'}, 2);
if (comparisonField == fields[0])
{
File.WriteAllLines(JobStart,
new string[] {jobStartLine + ";" + fields[1]});
break;
}
}
}
My BoxData = data1;data2;data3;data4;data5
At the moment data2 to data5 is getting in JobStart file.
Data5 shouldn't be included inside JobStart file.
I want to set data5 as a global variable.
How can I do this, I just cannot figure this out, need help.
This can help understanding my problem: How to compare 2 .csv files and create a new .csv containing parts from both csv files?
var foo = string.Empty;
try
{
var jobStartLine = File.OpenText(PackAuftrag).ReadLine();
var comparisonField = jobStartLine.Split(';')[4];
foreach (var line in File.ReadAllLines(BoxData))
{
var fields = line.Split(new char[] {';'}, 5).ToList();
foo = fields[4];
fields.RemoveAt(4);
if (comparisonField == fields[0])
{
File.WriteAllLines(JobStart,
new string[] {jobStartLine + ";" + String.Join(';', fields.ToArray())});
break;
}
}
}
This kinda resolves what I understood to be your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With