我有问题。我想在具有503 MB的日志文件中拆分文本。文件内部的格式为:
98.234.170.104 - - [05/Oct/2015:06:37:26 +0300] "GET /_/pk/ID_0000012978.ism/QualityLevels(1415496)/Fragments(video=61330800000) HTTP/1.1" 200 353301 "-" "Firefox/1.5" "-" rt=0.000 ut="-" cs=HIT
104.34.124.254 - - [05/Oct/2015:06:37:26 +0300] "GET /T/VZ/ID_0000013023.ism/QualityLevels(95999)/Fragments(audio=79666404082) HTTP/1.1" 200 40595 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko" "-" rt=0.000 ut="-" cs=HIT
有成千上万行这样的并排。第一行是拆分状态,如下:
User ip adress: 99.91.220.138
Event time: [05/Oct/2015:06:37:26 +0300]
Request method : GET
contentaccount:/R/0A/ID_0000013091.ism/QualityLevels(1469889)/Fragments(video=14795200000)
content type: ID_0000013091
content bitrate : QualityLevels(1469889) indicated by bold. Bitrate should be calculated like that 1400000, 800000, 400000,300000
content type: Fragments(video=14795200000) indicated by bold (video or audio could)
HTTP Status: 200
Total sent Bytes: 658377
User Agent: Firefox/1.5
Cache Status: cs={STATUS} : HIT (Cache kullanılmış), MISS(cache kullanılmamış)
我要做的是借助一个按钮选择文件,然后分析该文件和数据计数。
例如:
How many unique ip watched ? (Sample: 548)
How many unique content watched ? (Sample: 3242)
How much data has been sent ? (Sample: 500 GB)
Who is the watching most ? (Sample: 99.91.220.138)
What is the watching content most ? (Sample: ID_0000013091)
What is the watching bitrate oran (video or same audio). (Sample: 1400000 = %80 , 800000 = %10 , 400000 = %5 , 300000 = %5)
What is the watching browsers most ?. (Sample: IE = %20 , Chrome=%60 , Firefox = %20)
HTTP status oran (Sample: 2xx=%80, 403=%10, 404=%5, 5xx=%3, 3xx=%2)
到目前为止我一直在做什么?我正在开始编程的道路,所以我不能做很多事情。至少尝试使用“使用”按钮,然后选择文件并读取,但这是行不通的。我的电脑停止了。我认为文件太大。
这是我到目前为止使用的代码:
OpenFileDialog opn = new OpenFileDialog();
string line = "";
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (opn.ShowDialog() == DialogResult.OK)
{
StreamReader sr = new StreamReader(opn.FileName);
while (line!=null)
{
line = sr.ReadLine();
if (line !=null)
{
listBox1.Items.Add(line);
}
}
sr.Close();
}
}
private void Form1_Load(object sender, EventArgs e)
{
opn.Filter = "Text Files (.log)|*.log";
}
}
感谢您的帮助-这对我很重要。