Reputation: 60
I'm new to visual basic and have been tasked with creating an app that will read in various text files(.csv, .txt) and compare some of the data contained within.
I thought I would read in the files and convert them to datatables. Once I had them in a datatable I figured I could remove the unnecessary rows/columns and then sort and compare the pertinent info for differences. The difficulty is that the various files are formatted differently so I will need to get each type formatted correctly. Is this the best approach?
If so, I need help with the datatables. I have read in a .csv, parsed it into a datatable, but I'm having trouble with the logic/coding to get rid of the rows and columns that I don't need. Also, I'm not sure how to handle a row that has a cell with a comma seperated list of values that will need to be split into individual rows.
Thank you.
Upvotes: 1
Views: 293
Reputation: 15813
There are lots of ways to accomplish this. One way: Read each file, then convert it to a string array in a common format, such as csv. For each file, you can handle the issues of field location, field format, and multiple rows, and convert it to the common format. After you have the files in a consistent format, you can move them to a data table for sorting, comparison, etc.
Upvotes: 1