C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 09-23-2003, 04:17 AM   #1
Registered User
 
Join Date: Aug 2003
Posts: 93
checking values in a text file

Hi,

I am about to change a process that I have been writing recently, and before coding, I thought I would run through the idea here for comments.

The process currently reads two text files, (for example september.txt and august.txt) which contain records in the form of strings. The first file has one field checked which contains a text version of a date, and creates one of three new files. The three new files can have the current month, the previous 12 months [not including the current month] and everything else.

So there is now a new file, (for example OUT_FILE) which contains just september records.

A new check has to be made between OUT_FILE and august.txt on another field which has the text version of an account number. If the acc_id exists in august.txt and not in OUT_FILE, the record is written to a new file, (for example .DEL), if the acc_id exists in OUT_FILE and not in august.txt, the record is written to a new file, (for example .CRE), if the record exists in both files, it is ignored.

I thought of reading both files a record at a time and checking the acc_id's [which are guaranteed to be in numerical ascending order] and comparing their value...

e.g.
Code:
file 1    file 2
 123        123
 124        128
 125        129
 128        130
 129
would be processed like this
Code:
file 1    file 2
 123        123     - 123 = 123 no write
 124        128     - 124 < 128 / 124 to .DEL
 125                - 125 < 128 / 125 to .DEL
 128                - 128 = 128 no write
 129        129     - 129 = 129 no write
            130     - file 1 EOF everything else in file two written to .CRE
Each field value would be sent to an if test for evaluation and then decide on which file the record would be written to.

I am not sure if anyone can see any obvious pitfalls in this ?


tia,
darfader is offline   Reply With Quote
Old 09-23-2003, 06:25 AM   #2
End Of Line
 
Hammer's Avatar
 
Join Date: Apr 2002
Posts: 6,240
The principle looks OK to me.

The only pitfall I see is that you are assuming the input is in the correct order. If you are willing to assume this then fine, if there's a chance it won't be, you'll need another method.
__________________
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
Hammer is offline   Reply With Quote
Old 09-24-2003, 02:13 AM   #3
Registered User
 
Join Date: Aug 2003
Posts: 93
thanks Hammer,

I think I'll deliberately sort the files before working on them
darfader is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
disposing error dropper166 C# Programming 2 03-30-2009 11:53 PM
gcc link external library spank C Programming 6 08-08-2007 03:44 PM
Possible circular definition with singleton objects techrolla C++ Programming 3 12-26-2004 10:46 AM
Function is called and I am trying to open a file tommy69 C Programming 88 05-06-2004 08:33 AM
what does this mean to you? pkananen C++ Programming 8 02-04-2002 03:58 PM


All times are GMT -6. The time now is 02:26 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22