Saturday, December 5, 2009

Can somebody advise on the best way to perform this operation within a text file pls?

I am working with a system generated fixed position text file of multiple records, each record 200 characters in length. The



value of data at position 23 to position 32 is the 'coded' value for one of our Academic Programs (i.e. SSBA for the academic program 'Bachelor of Arts', in the Faculty of Social Science). Values need to be converted and



mapped to a uniform coding structure. Some examples of the conversions are as follows:



- SSBA, SCBA, FABA, HUBA need to be converted to U1BA and



- SCBS, ENBSC, KNBSC need to be converted to U1BSC.



My questions are as follows:



1. What method(s) might you use to convert these coded values?



2. What are some of the pros and cons of the method you would select?



I tried to use Find%26amp;Replace option in MS Word, but could not figure out how to set a range of positions from 23 to 32 for each record taking one row to work with.



May be there is another way to convert those coded values without Find%26amp;Replace command?



Thanks so much for any help!



Can somebody advise on the best way to perform this operation within a text file pls?met opera



I'd use Excel for this, which might seem like a weird answer but you'd be surprised what you can do with it (especially as your text strings are fixed length and the character you want to translate are always in the same position) and I've used it for text processing stuff like this before.



There's a few ways you could do this but at it's most basic level you can use the LEFT, MIDDLE and RIGHT worksheet functions to separate your strings into the three parts: everything leading up to the Academic Program code; the Academic Program code itself and finally the remainder of the record. One you've got that all extracted you can use an IF statement on the Academic Program code to transform it, then simply append all the pieces back together again. You can just copy/paste text data in and out of Excel so it's easy enough to import and export your records.



The above's a pretty dirty way of doing it but you can combine functions together once you get it all sorted and do it in much less steps. And obviously, if you've got a worksheet full of records, it only take a few mouse clicks to extend your forumula(s) to all the records once you get it working for the first one.



Can somebody advise on the best way to perform this operation within a text file pls?movie theatre opera theater



You could use the MID function within Excel to pick out the text between the two positions, and then use other functions to evaluate and/or change the text.
I wrote a custom application in C++ that did manipulation of records dumped from a database into a fixed position tape format for upload to a health care provider about 10 years ago. Very similar process.



The pros, it did exactly what I wanted, and it did it very quickly. It was free (my time was the only cost)



The cons, it took me a couple days to develop (there was a fairly complex ruleset) and I had the proprietary knowledge of a critical business function. The old "What happens if you get hit by a bus" situation, who would support it.



If you are interested, I could code something for you if you provide me exact specifications and requirements, I can give you a quote.



E-mail through answers if you want.

No comments:

Post a Comment

 
ltd