Skip to main content
edited body
Source Link
C.Evenhuis
  • 26.4k
  • 2
  • 60
  • 73

I want to compare two csv files and print the differences in a file. I currently use the code below to remove a row. Can I change this code so that it compares two csv files or is there a better way in c# to compare csv files?

 List<string> lines = new List<string>(); using (StreamReader reader = new StreamReader(System.IO.File.OpenRead(path))) { string line; while ((line = reader.ReadLine()) != null) { if (line.Contains(csvseperator)) { string[] split = line.Split(Convert.ToChar(schijdingstekenscheidingsteken)); if (split[selectedRow] == value) { } else { line = string.Join(csvseperator, split); lines.Add(line); } } } } using (StreamWriter writer = new StreamWriter(path, false)) { foreach (string line in lines) writer.WriteLine(line); } } 

I want to compare two csv files and print the differences in a file. I currently use the code below to remove a row. Can I change this code so that it compares two csv files or is there a better way in c# to compare csv files?

 List<string> lines = new List<string>(); using (StreamReader reader = new StreamReader(System.IO.File.OpenRead(path))) { string line; while ((line = reader.ReadLine()) != null) { if (line.Contains(csvseperator)) { string[] split = line.Split(Convert.ToChar(schijdingsteken)); if (split[selectedRow] == value) { } else { line = string.Join(csvseperator, split); lines.Add(line); } } } } using (StreamWriter writer = new StreamWriter(path, false)) { foreach (string line in lines) writer.WriteLine(line); } } 

I want to compare two csv files and print the differences in a file. I currently use the code below to remove a row. Can I change this code so that it compares two csv files or is there a better way in c# to compare csv files?

 List<string> lines = new List<string>(); using (StreamReader reader = new StreamReader(System.IO.File.OpenRead(path))) { string line; while ((line = reader.ReadLine()) != null) { if (line.Contains(csvseperator)) { string[] split = line.Split(Convert.ToChar(scheidingsteken)); if (split[selectedRow] == value) { } else { line = string.Join(csvseperator, split); lines.Add(line); } } } } using (StreamWriter writer = new StreamWriter(path, false)) { foreach (string line in lines) writer.WriteLine(line); } } 
added 6 characters in body
Source Link
Mylan
  • 115
  • 2
  • 10

I want to compare two csv files and print the differences in a file. I currently use the code below to remove a row. Can I change this code so that it compares two csv files or is there a better way in c# to compare csv files?

 List<string> lines = new List<string>(); using (StreamReader reader = new StreamReader(System.IO.File.OpenRead(path))) { string line; while ((line = reader.ReadLine()) != null) { if (line.Contains(csvseperator)) { string[] split = line.Split(Convert.ToChar(schijdingsteken)); if (split[selectedRow] == value) { } else { line = string.Join(csvseperator, split); lines.Add(line); } } } } using (StreamWriter writer = new StreamWriter(path, false)) { foreach (string line in lines) writer.WriteLine(line); } } 

I want to compare two csv files and print the differences in a file. I currently use the code below to remove a row. Can I change this code so that it compares two csv files or is there a better way to compare csv files?

 List<string> lines = new List<string>(); using (StreamReader reader = new StreamReader(System.IO.File.OpenRead(path))) { string line; while ((line = reader.ReadLine()) != null) { if (line.Contains(csvseperator)) { string[] split = line.Split(Convert.ToChar(schijdingsteken)); if (split[selectedRow] == value) { } else { line = string.Join(csvseperator, split); lines.Add(line); } } } } using (StreamWriter writer = new StreamWriter(path, false)) { foreach (string line in lines) writer.WriteLine(line); } } 

I want to compare two csv files and print the differences in a file. I currently use the code below to remove a row. Can I change this code so that it compares two csv files or is there a better way in c# to compare csv files?

 List<string> lines = new List<string>(); using (StreamReader reader = new StreamReader(System.IO.File.OpenRead(path))) { string line; while ((line = reader.ReadLine()) != null) { if (line.Contains(csvseperator)) { string[] split = line.Split(Convert.ToChar(schijdingsteken)); if (split[selectedRow] == value) { } else { line = string.Join(csvseperator, split); lines.Add(line); } } } } using (StreamWriter writer = new StreamWriter(path, false)) { foreach (string line in lines) writer.WriteLine(line); } } 
Source Link
Mylan
  • 115
  • 2
  • 10

Compare two csv files in C#

I want to compare two csv files and print the differences in a file. I currently use the code below to remove a row. Can I change this code so that it compares two csv files or is there a better way to compare csv files?

 List<string> lines = new List<string>(); using (StreamReader reader = new StreamReader(System.IO.File.OpenRead(path))) { string line; while ((line = reader.ReadLine()) != null) { if (line.Contains(csvseperator)) { string[] split = line.Split(Convert.ToChar(schijdingsteken)); if (split[selectedRow] == value) { } else { line = string.Join(csvseperator, split); lines.Add(line); } } } } using (StreamWriter writer = new StreamWriter(path, false)) { foreach (string line in lines) writer.WriteLine(line); } }