✅ Regex Result into CSV and Data Grid

I have a Regex that outputs results as Shown in Links https://regex101.com/r/EmbhHq/3 https://regex101.com/r/vYEy0x/1 I am looking to Export the Information into a CSV and Also to be able to display the results into a a Form Table (Probably a DataGridView)
regex101
regex101: build, test, and debug regex
Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET, Rust.
regex101
regex101: build, test, and debug regex
Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET, Rust.
2 Replies
Omnissiah
Omnissiah8mo ago
there is already a package for csv, something like csvhelper, there should be a csvwriter in it
Christian Dale
Christian DaleOP8mo ago
how would i be able to make it a Variable csv input. I was thinking a Switch method but it doesnt seam to work.
c#
public void CSVWrite(Match m)
{
var records = new List<FireInfo>();
switch (int.Parse(m.Groups["AlarmNum"].Value))
{
case 1:
new FireInfo { Time = m.Groups["Time"].Value, ActivationType = "Fire", AlarmNum = m.Groups["AlarmNum"].Value, X0 = m.Groups["X0"].Value, Y0 = m.Groups["Y0"].Value, Size0 = m.Groups["Size0"].Value };
break;
case 2:
new FireInfo { Time = m.Groups["Time"].Value, ActivationType = "Fire", AlarmNum = m.Groups["AlarmNum"].Value, X0 = m.Groups["X0"].Value, Y0 = m.Groups["Y0"].Value, Size0 = m.Groups["Size0"].Value, X1 = m.Groups["X1"].Value, Y1 = m.Groups["Y1"].Value, Size1 = m.Groups["Size1"].Value };
break;
case 3:
new FireInfo { Time = m.Groups["Time"].Value, ActivationType = "Fire", AlarmNum = m.Groups["AlarmNum"].Value, X0 = m.Groups["X0"].Value, Y0 = m.Groups["Y0"].Value, Size0 = m.Groups["Size0"].Value, X1 = m.Groups["X1"].Value, Y1 = m.Groups["Y1"].Value, Size1 = m.Groups["Size1"].Value, X2 = m.Groups["X2"].Value, Y2 = m.Groups["Y2"].Value, Size2 = m.Groups["Size2"].Value };
break;
case 4:
new FireInfo { Time = m.Groups["Time"].Value, ActivationType = "Fire", AlarmNum = m.Groups["AlarmNum"].Value, X0 = m.Groups["X0"].Value, Y0 = m.Groups["Y0"].Value, Size0 = m.Groups["Size0"].Value, X1 = m.Groups["X1"].Value, Y1 = m.Groups["Y1"].Value, Size1 = m.Groups["Size1"].Value, X2 = m.Groups["X2"].Value, Y2 = m.Groups["Y2"].Value, Size2 = m.Groups["Size2"].Value, X3 = m.Groups["X3"].Value, Y3 = m.Groups["Y3"].Value, Size3 = m.Groups["Size3"].Value };
break;
default:
break;
};
}
c#
public void CSVWrite(Match m)
{
var records = new List<FireInfo>();
switch (int.Parse(m.Groups["AlarmNum"].Value))
{
case 1:
new FireInfo { Time = m.Groups["Time"].Value, ActivationType = "Fire", AlarmNum = m.Groups["AlarmNum"].Value, X0 = m.Groups["X0"].Value, Y0 = m.Groups["Y0"].Value, Size0 = m.Groups["Size0"].Value };
break;
case 2:
new FireInfo { Time = m.Groups["Time"].Value, ActivationType = "Fire", AlarmNum = m.Groups["AlarmNum"].Value, X0 = m.Groups["X0"].Value, Y0 = m.Groups["Y0"].Value, Size0 = m.Groups["Size0"].Value, X1 = m.Groups["X1"].Value, Y1 = m.Groups["Y1"].Value, Size1 = m.Groups["Size1"].Value };
break;
case 3:
new FireInfo { Time = m.Groups["Time"].Value, ActivationType = "Fire", AlarmNum = m.Groups["AlarmNum"].Value, X0 = m.Groups["X0"].Value, Y0 = m.Groups["Y0"].Value, Size0 = m.Groups["Size0"].Value, X1 = m.Groups["X1"].Value, Y1 = m.Groups["Y1"].Value, Size1 = m.Groups["Size1"].Value, X2 = m.Groups["X2"].Value, Y2 = m.Groups["Y2"].Value, Size2 = m.Groups["Size2"].Value };
break;
case 4:
new FireInfo { Time = m.Groups["Time"].Value, ActivationType = "Fire", AlarmNum = m.Groups["AlarmNum"].Value, X0 = m.Groups["X0"].Value, Y0 = m.Groups["Y0"].Value, Size0 = m.Groups["Size0"].Value, X1 = m.Groups["X1"].Value, Y1 = m.Groups["Y1"].Value, Size1 = m.Groups["Size1"].Value, X2 = m.Groups["X2"].Value, Y2 = m.Groups["Y2"].Value, Size2 = m.Groups["Size2"].Value, X3 = m.Groups["X3"].Value, Y3 = m.Groups["Y3"].Value, Size3 = m.Groups["Size3"].Value };
break;
default:
break;
};
}
Want results from more Discord servers?
Add your server