예제 #1
0
        /// <summary>
        /// Get a CSV containing all the entries of this CSV which do not correspond to entries in the Other CSV.
        /// </summary>
        /// <param name="Other"></param>
        /// <returns></returns>
        public CSV NotIn(CSV Other)
        {
            CSV newCSV = new CSV();

            List <String> CommonKeys = new List <string>();

            foreach (String key in AllKeys)
            {
                if (Other.AllKeys.Contains(key))
                {
                    CommonKeys.Add(key);
                }
            }

            foreach (Dictionary <String, String> row in _Data)
            {
                Dictionary <String, String> strippedRow = new Dictionary <string, string>();
                foreach (String key in CommonKeys)
                {
                    strippedRow.Add(key, row[key]);
                }

                if (!Other.Contains(strippedRow))
                {
                    newCSV.Add(row);
                }
            }

            return(newCSV);
        }
예제 #2
0
파일: CSV.cs 프로젝트: mstrperson/Csv
        /// <summary>
        /// Get a CSV containing all the entries of this CSV which do not correspond to entries in the Other CSV.
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public CSV NotIn(CSV other)
        {
            CSV newCsv = new CSV();

            List <string> commonKeys = new List <string>();

            foreach (string key in AllKeys)
            {
                if (other.AllKeys.Contains(key))
                {
                    commonKeys.Add(key);
                }
            }

            foreach (Row row in _data)
            {
                Row strippedRow = new Row();
                foreach (string key in commonKeys)
                {
                    strippedRow.Add(key, row[key]);
                }

                if (!other.Contains(strippedRow))
                {
                    newCsv.Add(row);
                }
            }

            return(newCsv);
        }
예제 #3
0
파일: CSV.cs 프로젝트: mstrperson/Csv
        /// <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);
            }
        }
예제 #4
0
파일: CSV.cs 프로젝트: mstrperson/Csv
        /// <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);
            }
        }
예제 #5
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);
        }
예제 #6
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);
        }
예제 #7
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 (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);
        }