I have one A File and many input files ,All files have CSV format . I want to match text of one column of all input files with one of the column of A file . I have stored all column value of File A in HashSet for fast search.

1- Now iterate All input files uses First loop
2-       {iterate all elements in each file uses second loop 
3-           {
              and iterate all lines in hashset uses Third loop .
                    Store All lines in List and append true in the end at the end of line if Match found
                    Delete The input File

              //Removed Lines
4-            //      iterate through all stored lines
             //    {
            //      Write in same file
            //     }

             //Added Lined 


1-When i find the match ,i have to make change input File , For this purpose i have to use FileWriteStream, a Collection to store lines and another loop. Delete the File and write again. Is there any optimal solution to achieve this

2- I have used linear Search in order to Search the text in A file .Is it 'okay' to use Dictionary so that i takes O(1) to get the element.

3- Is there any good optimal way to read all this .using Oledb 'can i use the query'?

  • 1) If the file is small enough to fit into memory, please consider using File.WriteAllLines 2) I'm not sure why you're iterating over the HashSet; I think you should be using the HashSet to perform fast lookups - not iterating over each line. – J Trana Sep 17 '14 at 0:59
  • @JTrana I am iterating over collection because i have to match a part in row rather than whole row . – Charlie Sep 18 '14 at 9:12
  • 2
    I believe this question was answered in another thread: [How to use SQL against a CSV file][1] [1]: stackoverflow.com/questions/10624286/… – WellerEE May 19 '15 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.