albert albert

albert albert

  • NA
  • 524
  • 0

Making colums of text file

Aug 26 2014 9:03 AM
Hi everybody,
 
I have this:
 
[code]
 
private void button2_Click(object sender, EventArgs e)
{
DataTable table = new DataTable();
table.Columns.Add("colomn1.");
table.Columns.Add("colomn2.");
table.Columns.Add("Column3");
table.Columns.Add("column4");
//table.Columns.Add("column5");
//table.Columns.Add("column6");
using (StreamReader sr = new StreamReader(@"test4.txt"))
{
string line;
while (!sr.EndOfStream)
{
//string[] parts = sr.ReadLine().Split("\t");
var parts = new char[] {'\t'};
//string[] parts = line.Split(",");
//table.Rows.Add(parts[0], parts[1], parts[2], parts[3]);
// parts.Count();
table.Rows.Add(parts[0]);
}
}
dataGridView1.DataSource = table;
// dataGridView1.DataBind();
}
 
[/code] 
 
 
and this is the text file:  
 
2014-08-25 14:20:43,949 DEV belkbyavlahok0jrvoutn2xd 21 R O http://10.123.9.66:80/solr_3.6/wiewaswie_live/select/ qt=standard_a2aperson&q=*:*&fq=(nosyn_name_last_exact:(qxqroelofqxq))&fq=(nosyn_name_patronym_exact:(qxqharmsqxq))&spellcheck.q=(qxqroelofqxq qxqharmsqxq)&fq={!tag%3Dalldoctypes}doc_type:1&fq=date_main:[0 TO 18133112]&facet.query={!ex%3Dalldoctypes}doc_type:3 AND (b_public:1)&facet.query={!ex%3Dalldoctypes}doc_type:2 AND (b_public:1)&spellcheck=true&spellcheck.count=-3&start=0&sort=name_last asc, score desc&omitHeader=true 
 
And I want to make seperated columns in the grid: so for:  2014-08-25 14:20:43,949 DEV belkbyavlahok0jrvoutn2xd 21 R O.
 
separeted date  time dev belkbyavlahok0jrvoutn2xd  21 R  O, etc.
 
Thank you 

Answers (1)