| | |
removing duplicate lines from a text file while maintaining order of text
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2007
Posts: 18
Reputation:
Solved Threads: 1
Hi
Hope u r all well... here is my problem... i want to remove duplicate entries from a text file while maintaining the order of the text say if the text file contains
123zabc
456def
123abc
456def.
123def
456def
123abc
i want the result to be like
123zabc
456def
123abc
456def.
123def
i am currently using unix system calls to do this but its not working right every time...
i am using sort and unique function of unix...anyways
can some one please help me out with this... i do not mind getting the answer either in c or c++..
thanks
Hope u r all well... here is my problem... i want to remove duplicate entries from a text file while maintaining the order of the text say if the text file contains
123zabc
456def
123abc
456def.
123def
456def
123abc
i want the result to be like
123zabc
456def
123abc
456def.
123def
i am currently using unix system calls to do this but its not working right every time...
i am using sort and unique function of unix...anyways
can some one please help me out with this... i do not mind getting the answer either in c or c++..
thanks
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
•
•
Join Date: Aug 2007
Posts: 18
Reputation:
Solved Threads: 1
the thing is the size of the file is in megabytes around 50 or 60 megabytes each.. i am keeping a record of all the files with in a system including system folders,hidden files e.t.c.... if i read the entire file in an array that would make the performance of the system slow...and i do not want to do that...anyhow i knew someone will say that i should have been clearer my fault my apologizes...
•
•
•
•
let me put it this way about 17000 lines in the file take up to 1 to 1.5 megabytes so if i do as u suggested...even in this case i would need around 17000 * 1000 matches in most cases... and 17000*17000 matches in worst case only for 1/50 th of the file
•
•
•
•
i wonder if ancient dragon is online ...he would have solved this in a minute....
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
•
•
Join Date: Dec 2006
Posts: 1,089
Reputation:
Solved Threads: 164
you could use a std::set< std::string > ( or a map or a hashmap as you suggested ) to check for the duplicates. see this thread: http://www.daniweb.com/forums/thread81348.html
![]() |
Similar Threads
- Help!!!! Filtering A Text File (C++)
- I want to create text file on clients local drive.Please help. (ASP.NET)
- using a "for" loop to read a text file (VB.NET)
- Need Help in Reading characters from a text file (C++)
- Homework: filling array from text file (VB.NET)
- Inputting text file data into an array, please help! (C++)
- removing duplicate lines in unix (Shell Scripting)
- Save a text file in an csv.file with ascii? (PHP)
Other Threads in the C++ Forum
- Previous Thread: help me..
- Next Thread: open a folder in graphical mode using c++ and linux os
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion count data database delete deploy desktop developer directshow dll dynamiccharacterarray email encryption error file forms fstream function functions game getline google graph homeworkhelp homeworkhelper iamthwee ifstream input int integer lib linkedlist linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text tree unix url vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






