none
Excel Comparison RRS feed

  • Question

  • Hi all,

     

    There is a scenario where I have manually to use a .csv file which contains the 1000s sets of number in a single column. After every time I use this .csv file data in my custom program, it account those numbers in Database which again I have to extract to a .csv file.

    So now i have two set of .csv file and I need to compare the data present in the file1.csv with the file2.csv and delete all those data which are present in the column A of the file2.csv in the file1.csv and generate a new file3.csv so that i replace the file3.csv in the place of file1.csv

    This a regular manual work apart from my development. Hence i decide to develop a tool in VB so that it reduces my work.

    I need help in comparison of the each cell of column across the two excel/.csv file and generate this into third file.

    Since i m a newbie into VB world, can i expect little more help from this forum...

     

    Thank You

     

    • Moved by Mark Liu-lxfModerator Friday, October 21, 2011 3:44 AM vba question (From:Visual Basic General)
    Sunday, October 16, 2011 10:38 AM

All replies

  • There is a scenario where I have manually to use a .csv file which contains the 1000s sets of number in a single column. After every time I use this .csv file data in my custom program, it account those numbers in Database which again I have to extract to a .csv file.

    So now i have two set of .csv file and I need to compare the data present in the file1.csv with the file2.csv and delete all those data which are present in the column A of the file2.csv in the file1.csv and generate a new file3.csv so that i replace the file3.csv in the place of file1.csv

    This a regular manual work apart from my development. Hence i decide to develop a tool in VB so that it reduces my work.

    I need help in comparison of the each cell of column across the two excel/.csv file and generate this into third file.

    Since i m a newbie into VB world, can i expect little more help from this forum...

    "I know the basic how to create form, controls and how to use openfiledialog to select the files, i need to know how to compare each cell with that files and how to store that in new file"

     

    Thank You


    Sunday, October 16, 2011 11:38 AM
  • I'm sorry, the question is not related to the VB IDE. I'm not sure if you're talking about VBA (inside Excel) or VB.Net. If it's VBA, this is the right group.


    Armin
    Sunday, October 16, 2011 2:23 PM
  • If I understand correctly you have two csv files that you wish to compare where the comparison is to be done on the first wo columns. You want to remove entries from the first file that match those in the second file.

    There are a number of ways to do this depending on the contents of the files. One way would be to read the first one into an list. Then loop through the second one, if a match is found remove the item from the list, at the end write the list to a new file.

    Another might be to read both files into lists and use LINQ to extract the non-matching items then write them to a file.

    There is an ambiguity in that you refer to Excel files and csv as yhough they were the same - that is not the case.

    Cannot be more explicit since I don't know the layouts of the files and how the comparison is to be done.


    Regards David R
    ---------------------------------------------------------------
    Every program eventually becomes rococo, and then rubble. - Alan Perlis
    The only valid measurement of code quality: WTFs/minute.
    Sunday, October 16, 2011 4:39 PM
  • I think Riced has some good advice -- try to get the data into something that can be compared through LINQ, which would be the easiest way to perform this action.  I'm not sure a straight List(Of String) would do it since keeping the cell locations straight could prove difficult (maybe not if the files are very normalized), so you might need to make a simple class that has a property for the cell address and a property for the value.  That way your LINQ query can more strongly join the two lists based on the address.

    Sunday, October 16, 2011 11:28 PM

  • Hi DeepakNS,


    Welcome to the MSDN forum.

    I find that you have the correct same post in this forum. At here the members have given you the helpful information.
    For better support, I will merge this thread to another. Sorry for any inconvenience.


    Mark lxf [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, October 18, 2011 2:01 AM
    Moderator
  • I agree with armin. This is not the correct forum.

    Renee


    "MODERN PROGRAMMING is deficient in elementary ways BECAUSE of problems INTRODUCED by MODERN PROGRAMMING." Me
    Tuesday, October 18, 2011 5:19 AM