Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void ReadData(TextReader Source)
- {
- string txt = Source.ReadToEnd();
- List<String> lst = new List<String>();
- string[] items = txt.Split(Convert.ToChar(Environment.NewLine));
- DataTable dt = new DataTable();
- foreach (string s in items) // actual rows
- {
- string[] cols = null;
- if (s.Contains(",")) // check if the row has multiple columns
- {
- cols = s.Split(',');
- DataRow r = dt.NewRow();
- foreach (string col in cols) // actual columns
- {
- dt.Columns.Add();
- }
- int i = 0;
- foreach (string col in cols) // actual columns
- {
- r[i] = col;
- i++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement