StreamReader reader = new StreamReader(@"C:\Users\Faran\Documents\Visual Studio 2015\Projects\ConsoleApplication1\ConsoleApplication1\cast.csv");
StreamReader reader1 = new StreamReader(@"C:\Users\Faran\Documents\Visual Studio 2015\Projects\ConsoleApplication1\ConsoleApplication1\actors.csv");
StreamWriter writer = new StreamWriter(@"C:\Users\Faran\Documents\Visual Studio 2015\Projects\ConsoleApplication1\ConsoleApplication1\directorRevenue.csv");
string line = null,line1 = null;
bool chk = false;
string[] token = null;
string output = null;
while ((line = reader.ReadLine()) != null)
{
output = null;
chk = false;
token = line.Split(',');
while ((line1 = reader1.ReadLine()) != null)
{
chk = false;
var token1 = line1.Split(',');
for (int i = 0; i < token.Length; i++)
{
if (token[i].Contains(token1[0]) || token1[0].Contains(token[i]) || token[i] == token1[0])
{
chk = true;
output = token[i] + "," + token1[1];
break;
}
}
}
writer.WriteLine(output);
}
writer.Close();
reader.Close();
reader1.Close();
” 从1个文件“CAST”中读取并找到“ACTORS”文件中的TOKEN [i]以获得其收入。
ACTORS FILE
Amy Adams,2126
Ben Affleck,2288.8
Casey Affleck,911.5
Dianna Agron,131.6
Jessica Alba,952.3
Alan Alda,753
琼·艾伦,854.3 蒂姆艾伦,1763年 伍迪艾伦,461.3Mathieu Amalric,300.7
Gillian Anderson,146.4
Julie Andrews,925.6
Jennifer Aniston,1627.1
Aziz Ansari,168.6
CAST FILE
Amy Adams,Alex Descas
Ben Affleck,Melina Matthews
Jaenada,Casey Affleck
Bulent Dincer,Dianna Agron
Sarah Steele,Jessica Alba
Jerome Ro Brooks,Alan Alda “