[Message Deleted]
-
Sounds like a homework problem. :~ Anyway, could you describe exactly what the difference between the two formats is?
-
Sounds like a homework problem. :~ Anyway, could you describe exactly what the difference between the two formats is?
You need to state exactly what type of format or organising structure you are trying to acheive.
-
You need to state exactly what type of format or organising structure you are trying to acheive.
Are you trying to just get rid of the duplicated record?
-
You need to state exactly what type of format or organising structure you are trying to acheive.
-
Are you trying to just get rid of the duplicated record?
-
1- create a structure (or class) that contains the fields for each record ; create/use a collection that holds your records 2- in a loop : 3- read one line of the file, knowing that you know the format, you can skip unwanted lines. 4- skip line if unwanted; if line contains (is?) "============" and it's the first one, then you know it's a new record. 5- read the next few lines to fill a record. 6- look in your collection to see if new record is already there; if it's not there, add it to your collection. 7- once you've read all the lines, 8- write back the data line-by-line in a new file. (steps 5,6 can be optimized to not have to create a new record until you've find if the item is not in the collection).
This signature was proudly tested on animals.
-
-
Then in any environment, you need to qualify what you wish to discard. You need to place a field (that you specify) into a list box and disallow the duplication of a matching field. If the field or database.component is new then allow the record to be copied to a new file. At the end (after testing) simply replace your old file with the new one. I'm assuming your running a few thousand records.
-
1- create a structure (or class) that contains the fields for each record ; create/use a collection that holds your records 2- in a loop : 3- read one line of the file, knowing that you know the format, you can skip unwanted lines. 4- skip line if unwanted; if line contains (is?) "============" and it's the first one, then you know it's a new record. 5- read the next few lines to fill a record. 6- look in your collection to see if new record is already there; if it's not there, add it to your collection. 7- once you've read all the lines, 8- write back the data line-by-line in a new file. (steps 5,6 can be optimized to not have to create a new record until you've find if the item is not in the collection).
This signature was proudly tested on animals.
-
I will not give you code (dummy or not); I want you to try to come up with a solution based on the suggestions we've given you. Once you've tried one, two, or even more solutions to your problem (which sounds like a homework), and you still have problems, then we will gladly be of help of precise problems you can still have. It can be also easier to ask questions to your teachers and/or teaching assistants and/or computer lab assistants; or even fellow students.
This signature was proudly tested on animals.
-
Then in any environment, you need to qualify what you wish to discard. You need to place a field (that you specify) into a list box and disallow the duplication of a matching field. If the field or database.component is new then allow the record to be copied to a new file. At the end (after testing) simply replace your old file with the new one. I'm assuming your running a few thousand records.
Ric Ashton wrote:
I'm assuming your running a few thousand records.
Don't be so generous. This is obviously a homework assignment.
-
The first order of business would be to read the data into some sort of data structure. Until you can get that far, eliminating duplicates is irrelevant.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons