private void mergeEqualRows() { List<CountriesTableRow> newList = new List<CountriesTableRow>(); CountriesTableRow row = new CountriesTableRow(rows[0]); for (int i = 1; i < rows.Count; i++) { if (rows[i].CompareTo(rows[i - 1]) != 0) { newList.Add(row); row = new CountriesTableRow(rows[i]); } } newList.Add(row); rows = newList; }
private CountriesTableRow regexRaiting(String line) { if (line == "") throw new NotAFilmException(); String result = line.Trim(); Regex rgx = new Regex(@"\t+"); CountriesTableRow countries = new CountriesTableRow(); int year = 0; string[] array = rgx.Split(result); if (array.Length != 2) throw new NotAFilmException(); countries.Country = array[1].Trim(); result = array[0].Trim(); rgx = new Regex(@"\s+\([1-2]\d{3}[\)\\\/]"); array = rgx.Split(result); countries.FilmTitle = array[0].Trim(); var k = rgx.Matches(result); if (k.Count > 0) { String temp = k[0].Value.Trim(); temp = temp.Substring(1, 4); //temp = temp.Replace("(","").Replace(")", ""); int.TryParse(temp, out year); countries.Year = year; } if (year == 0) throw new NotAFilmException(); return countries; }