Пример #1
0
        /// <summary>
        /// finds CSV values. filters out non numeric values
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static List <float> extractValues(string str)
        {
            List <string> vals  = ParsingUtils.separateCSV(str);
            List <float>  valsF = new List <float>();

            foreach (var v in vals)
            {
                string cs = ParsingUtils.filterOutNonNumericValues(v);
                if (cs.Length > 0)
                {
                    valsF.Add(float.Parse(cs));
                }
            }
            return(valsF);
        }
Пример #2
0
        public static List <Dictionary <string, string> > readTable(string[] tableLines)
        {
            tableLines = ParsingUtils.clearComments(tableLines);

            List <string> headerLine = ParsingUtils.separateCSV(tableLines[0]);
            List <Dictionary <string, string> > res = new List <Dictionary <string, string> >();

            for (int l = 1; l < tableLines.Count(); ++l)
            {
                Dictionary <string, string> lineVals = new Dictionary <string, string>();
                List <string> vals = ParsingUtils.separateCSV(tableLines[l]);
                for (int vi = 0; vi < vals.Count; ++vi)
                {
                    lineVals[headerLine[vi].Trim()] = vals[vi].Trim();
                }
                res.Add(lineVals);
            }
            return(res);
        }