Exemplo n.º 1
0
        private IEnumerable <ICsvRow> where_clause <T>(string name, T value, Func <string, T, bool> match)
        {
            int columnIndex = CsvHelpers.NameToColumnIndex(_columns, name);

            foreach (var line in File.ReadLines(_path))
            {
                if (IsNullOrWhiteSpace(line))
                {
                    continue;
                }

                var field = CsvHelpers.ParseField(line, columnIndex);

                if (IsNullOrWhiteSpace(field))
                {
                    continue;
                }

                if (!match(field, value))
                {
                    continue;
                }

                yield return
                    (CsvRow.New(_columns, line));
            }
        }
Exemplo n.º 2
0
        string ICsvRow.this[string name]
        {
            get
            {
                int index = CsvHelpers.NameToColumnIndex(_columns, name);

                if (index >= _fields.Length)
                {
                    return(null);
                }

                return(_fields[index]);
            }
        }