C# でテキスト ファイルを解析しようとしています。「Rows_affected」の値が500より大きい行番号を抽出したい。
ここに私のテキストファイルのサンプルがあります..
Query_time: 0.000268 Lock_time: 0.000097 Rows_sent: 1 Rows_examined: 38 Rows_affected: 0 Rows_read: 1
Query_time: 0.000308 Lock_time: 0.000115 Rows_sent: 0 Rows_examined: 38 Rows_affected: 500 Rows_read: 0
Query_time: 0.000169 Lock_time: 0.000057 Rows_sent: 0 Rows_examined: 38 Rows_affected: 300 Rows_read: 0
Query_time: 0.000296 Lock_time: 0.000111 Rows_sent: 0 Rows_examined: 38 Rows_affected: 50 Rows_read: 0
Query_time: 0.000238 Lock_time: 0.000081 Rows_sent: 0 Rows_examined: 38 Rows_affected: 1 Rows_read: 0
Query_time: 0.000318 Lock_time: 0.000110 Rows_sent: 1 Rows_examined: 38 Rows_affected: 600 Rows_read: 1
これは私のコードです...
int lineNumb = 0;
using (System.IO.StreamReader file = new System.IO.StreamReader(openFileDialog1.FileName)) {
while ((line = file.ReadLine()) != null) {
lineNumb++;
if (line.StartsWith("# Query_time:")) {
int value = Convert.ToInt32(line.Split(':')[5].Split(' ')[1]);
if (value > 500) {
listBox1.Items.Add(lineNumb.ToString() + " > " + value.ToString());
}
int lineNumb = 0;
using (System.IO.StreamReader file = new System.IO.StreamReader(openFileDialog1.FileName))
{
while ((line = file.ReadLine()) != null)
{
lineNumb++;
if (line.StartsWith("# Query_time:"))
{
int value = Convert.ToInt32(line.Split(':')[5].Split(' ')[1]);
if (value > 500)
{
listBox1.Items.Add(lineNumb.ToString() + " > " + value.ToString());
}
}
}