Esempio n. 1
0
        /// <summary>
        /// Query this table and find all rows that match a set of regular expressions.
        /// Use this to find all rows where a data fits a particular set of regular expressions.
        /// for example, find all rows in a contact list where the Phone Number has a 540 area code
        /// and the street address is in a particular town.
        /// </summary>
        /// <param name="primaryKey"></param>
        /// <returns></returns>
        public CSV this[Dictionary <string, Regex> primaryKey]
        {
            get
            {
                CSV output = new CSV();
                foreach (Row row in this)
                {
                    foreach (string key in primaryKey.Keys)
                    {
                        if (!row.ContainsKey(key) || !primaryKey[key].IsMatch(row[key]))
                        {
                            continue;
                        }
                    }

                    output.Add(row);
                }

                return(output);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Query this table and find all rows that match a set of values.
        /// </summary>
        /// <param name="primaryKey"></param>
        /// <returns></returns>
        public CSV this[Row primaryKey]
        {
            get
            {
                CSV output = new CSV();
                foreach (Row row in this)
                {
                    foreach (string key in primaryKey.Keys)
                    {
                        if (!row.ContainsKey(key) || !row[key].Equals(primaryKey[key]))
                        {
                            continue;
                        }
                    }

                    output.Add(row);
                }

                return(output);
            }
        }
Esempio n. 3
0
        public CSV PullRowsMatchingPrimaryKeysWith(CSV other)
        {
            CSV output = new CSV();

            foreach (Row row in other._data)
            {
                try
                {
                    output.Add(this.Find(row));
                }
                catch (KeyNotFoundException)
                {
                    continue;
                }
                catch (InvalidDataException)
                {
                    continue;
                }
            }

            return(output);
        }
Esempio n. 4
0
        /// <summary>
        /// Gets the extra rows from this csv which are not present in the other csv.
        /// </summary>
        /// <returns>The extra rows from.</returns>
        /// <param name="other">Other.</param>
        public CSV GetExtraRowsFrom(CSV other)
        {
            CSV output = new CSV();

            foreach (Row row in this._data)
            {
                bool found = false;
                foreach (Row checkRow in other._data)
                {
                    if (CompareUniqueFields(checkRow, row))
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    output.Add(row);
                }
            }

            return(output);
        }
        /// <summary>
        /// Gets the extra rows from this csv which are not present in the other csv.
        /// </summary>
        /// <returns>The extra rows from.</returns>
        /// <param name="other">Other.</param>
        public CSV GetExtraRowsFrom(CSV other)
        {
            CSV output = new CSV();

            foreach (Dictionary <String, String> row in this.Data)
            {
                bool found = false;
                foreach (Dictionary <string, string> checkRow in other.Data)
                {
                    if (CompareUniqueFields(checkRow, row))
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    output.Add(row);
                }
            }

            return(output);
        }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Csv.ExtendedCSV"/> class.
 /// </summary>
 /// <param name="toExtend">To extend.</param>
 /// <param name="uidfields">Uidfields.</param>
 public ExtendedCSV(CSV toExtend, List <string> uidfields) : base(toExtend._data)
 {
     this.UniqueFields = uidfields;
 }