private static GenresTableRow regexGenres(String line) { if (line == "") throw new NotAFilmException(); String result = line.Trim(); Regex rgx = new Regex(@"\t+"); GenresTableRow genres = new GenresTableRow(); int year = 0; string[] array = rgx.Split(result); if (array.Length != 2) throw new NotAFilmException(); genres.FilmGenres = (int)Math.Pow(2, checkFilmInListOfGenres(array[1])); result = array[0].Trim(); rgx = new Regex(@"\s+\([1-2]\d{3}[\)\\\/]"); array = rgx.Split(result); genres.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); genres.Year = year; } if (year == 0) throw new NotAFilmException(); return genres; }
private void mergeEqualRows() { List<GenresTableRow> newList = new List<GenresTableRow>(); GenresTableRow genre = new GenresTableRow(rows[0]); for (int i = 1; i < rows.Count; i++) { if (rows[i].CompareTo(rows[i - 1]) == 0) { genre.FilmGenres += rows[i].FilmGenres; } else { newList.Add(genre); genre = new GenresTableRow(rows[i]); } } newList.Add(genre); rows = newList; }