1

I am working on an application which will compare two datasets. This will take two .csv files and compare the data between them. I have to read the .csv files and compare the file field to field. Now I don't want to waste time by comparing columns that are already matching when summed. currently, I am storing the list as DataTable. How can I find the field datatype if it is an integer or date or decimal or string?

Is there an easy way to do or a library available?

Please help.

  • Any framework is going to make you define what the data type should be for the column. For an example of what could be done check out this question. https://stackoverflow.com/questions/3507498/reading-csv-files-using-c-sharp – Blast_dan Oct 16 '17 at 15:18
  • No, not really. if a column contains values such as `1, 1, 0, 1` it could be int, float, double, a string or even boolean. if it contains values such as `1.1, 2.3` it could be double or float or maybe simply a string. Basically, everything in a csv is a string unless you know for sure it's something else. – Zohar Peled Oct 16 '17 at 15:24
  • As Zohar Peled mentioned, I am having a problem to determine if it is int or decimal or float. Also, I can loop through the first record and find by "tryparse" to find the datatype. what if the later record has a decimal or a string in it. should I loop through each record to determine the datatype? Is there a fast and simple way to do it? – Hari Krishna Gaddipati Oct 16 '17 at 15:45
  • Keep everything as strings. Otherwise you will be forced to make assumptions that might lead you to faulty code. – Zohar Peled Oct 18 '17 at 07:51

0 Answers0