Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

append from type delimited 1

Status
Not open for further replies.

infinitelo

Programmer
Mar 7, 2001
319
i recieve a file on a regualar basis that is "," delimited and there are always a few records that don't load right. ive asked for corections on the source side to no avail, any sugesstions on "fixing" incomming data?
 
I guess it all depends on what the problems are. Are they always the same record? Are they always the same type of problem causing the error? Is it easy for you to fix the problem? Is the data more critical to you or the source side? For Example: If it means they don't get paid if the data isn't correct, I think you have a leverage point.

Obviously you can write your own parsing program using low-level IO - it just depends on how important it is. (Development cost vs. manually fixing the errors)

Rick
 
I had to do that one time and ran into the same problem.
What I did was:
1. create/open 2 new files with =fcreate().
2. Opened the input file with fopen()
3. Read the file one line at a time with fgets()
4. counted the number of commas
5. if the comma count matched the number of fields I wrote the line to the new file with fputs()
6. if the comma count did not match, wrote the line to the the other file I opened.
7. Imported the data from the file where the comma count was correct.
8. opened the miscount comma file in an editor and repaired the problem on each line.
9. Imported the data from the repaired file. David W. Grewe
Dave@internationalbid.com
 
The file has always had a few "wierd" records and money is not an issue as the file is just a "backup" the boss like to have counts from. it just bugs me when stuff doesnt work right.

Thanks for the simple solution dave, that looks like what i was fishing for. (i just hope the errors file is smaller than the "good" file)


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top