Пример #1
0
        private static List<DbRow> ParseFile(CgmFileInfo cgmFileInfo)
        {
            var dbRows = new List<DbRow>();
            using (var sr = new StreamReader(cgmFileInfo.FullName))
            {
                var rows = 0;
                string line;
                string[] colNameList = { };

                while ((line = sr.ReadLine()) != null)
                {
                    var columns = line.Split('\t');
                    if (string.IsNullOrEmpty(columns[2]))
                    {
                        break;
                    }

                    //first row contains the column names
                    if (rows == 0)
                    {
                        colNameList = (string[])columns.Clone();
                        rows++;
                        continue;
                    }

                    var dbRow = new DbRow();
                    //skip the first two columns - don't need - that's why i starts at 2
                    for (int i = 2; i < 13; i++)
                    {

                        var col = columns[i];
                        if (col == "High")
                            col = "999";
                        if (col == "Low")
                            col = "0";

                        var colName = colNameList[i];

                        var colValName = new DbColNameVal { Name = colName, Value = col };

                        dbRow.ColNameVals.Add(colValName);
                    }
                    dbRows.Add(dbRow);
                }
            }
            return dbRows;
        }