Posted by Anonymous on Tue 26 Aug 11:28
report abuse | download | new post
- using System;
- using System.Text.RegularExpressions;
- using System.Data;
- using System.Collections;
- namespace retest
- {
- class Program
- {
- static void Main(string[] args)
- {
- String fileContent = sr.ReadToEnd();
- sr.Close();
- String cp = @"\s+(-?[\d.]+)";
- MatchCollection mc = re.Matches(fileContent);
- foreach (Match m in mc)
- {
- table.Rows.Add(new object[] { m.Groups[1].Value, m.Groups[2].Value, m.Groups[3].Value, m.Groups[4].Value, m.Groups[5].Value, m.Groups[6].Value, m.Groups[7].Value, m.Groups[8].Value, m.Groups[9].Value, m.Groups[0].Value});
- }
- table.AcceptChanges();
- DataRow[] allRows;
- allRows = table.Select();
- DataRow[] foundRows;
- for (int ii = 0; ii < allRows.Length; ii++)
- {
- if (!list.Contains(allRows[ii]["Code"]))
- {
- list.Add(allRows[ii]["Code"]);
- string expression = "Code = '" + allRows[ii]["Code"] + "'";
- foundRows = table.Select(expression);
- if (foundRows.Length == 2)
- {
- float Open = (float)foundRows[0]["Open"] + (float)foundRows[1]["Open"];
- float High = (float)foundRows[0]["High"] + (float)foundRows[1]["High"];
- float Low = (float)foundRows[0]["Low"] + (float)foundRows[1]["Low"];
- float Close = (float)foundRows[0]["Close"] + (float)foundRows[1]["Close"];
- float Change = (float)foundRows[0]["Change"] + (float)foundRows[1]["Change"];
- float Trade = (float)foundRows[0]["Trade"] + (float)foundRows[1]["Trade"];
- float Volume = (float)foundRows[0]["Volume"] + (float)foundRows[1]["Volume"];
- float Value = (float)foundRows[0]["Value"] + (float)foundRows[1]["Value"];
- string newline = foundRows[0]["Code"]+" "+Open+" "+High+" "+Low+" "+Close+" "+Change+" "+Trade+" "+Volume+" "+Value+Environment.NewLine;
- string line0 = (string)foundRows[0]["Line"];
- string line1 = (string)foundRows[1]["Line"];
- fileContent = fileContent.Replace(line1, "");
- Console.WriteLine("removed: " + line1);
- fileContent = fileContent.Replace(line0, newline);
- Console.WriteLine(" added: " + newline);
- }
- }
- }
- sw.Write(fileContent);
- sw.Close();
- }
- }
- }
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.