-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfileFilterer
114 lines (82 loc) · 3.87 KB
/
fileFilterer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace fileFilterer
{
class Program
{
static void Main(string[] args)
{
//using (StreamReader reader = new StreamReader(@"C:\Users\Joel Gahr\Desktop\c# projects\csFinalProj1\csFinalProj1\ratings.txt"))
//{
// using (StreamWriter writer = new StreamWriter("Ratings2.txt"))
// {
// string line;
// while ((line = reader.ReadLine()) != null)
// {
// string[] row = line.Split('\t');
// if (int.Parse(row[2]) < 1000)
// continue;
// else
// {
// writer.WriteLine(line);
// Console.WriteLine(line);
// }
// }
// }
//}
//using (var generalInfoReader = new StreamReader(@"C: \Users\Joel Gahr\Desktop\yearGenreType.txt"))
//{
// using (var ratingsReader = new StreamReader("Ratings2.txt"))
// {
// using (var movie_writer = new StreamWriter("movieInfo.txt"))
// {
// string genera_line;
// string ratings_line;
// while ((ratings_line = ratingsReader.ReadLine()) != null)
// {
// while ((genera_line = generalInfoReader.ReadLine()) != null && int.Parse(ratings_line.Substring(2,7)) >= int.Parse(genera_line.Substring(2,7)))
// {
// string[] ratings_row = ratings_line.Split('\t');
// string[] genera_row = genera_line.Split('\t');
// if (genera_row[0] == ratings_row[0] && genera_row[1] == "movie" && genera_row[5] != @"\N" && genera_row[4] == "0")
// {
// movie_writer.WriteLine(genera_line + '\t' + ratings_row[1]);
// Console.WriteLine(genera_line + '\t' + ratings_row[1]);
// break;
// }
// }
// }
// }
// }
//}
using (var countryReader = new StreamReader(@"C:\Users\Joel Gahr\Desktop\data (2).tsv"))
{
using (var movieInfoReader = new StreamReader("movieInfo.txt"))
{
using (var movieInfoWriter = new StreamWriter("movieInfoFinal.txt"))
{
string country_line;
string genera_line;
while ((genera_line = movieInfoReader.ReadLine()) != null)
{
while ((country_line = countryReader.ReadLine()) != null /*&& int.Parse(country_line.Substring(2, 7)) >= int.Parse(genera_line.Substring(2, 7))*/)
{
string[] country_row = country_line.Split('\t');
string[] genera_row = genera_line.Split('\t');
if (country_row[0] == genera_row[0] && country_row[7] == "1")
{
movieInfoWriter.WriteLine(genera_line + '\t' + country_row[4]);
Console.WriteLine(genera_line + '\n' + country_row[4]);
break;
}
}
}
}
}
}
}
}
}