|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Text search and replace in column delimitated text files.I have text files that contain a several hundred to thousands of column
delimitated records. I need to replace a two digit year value from 08 to 42 in four places in each record at characters 4 and 5; 29 and 30; 60 and 61; as well as 153 and 154. Anybody have a quick how-to to accomplish this? I have never done this type of large search and replace where the only unique identifier of the data is it's position in the string. Any creative ideas on a way to do this without writing a large string processor to loop over all the records doing several string chopping and concactination operations? I have available to me the default Windows XP Professional and Windows Office 2000 programs, Dreamweaver and Crimson Editor as well as Java, Perl and ColdFusion programming languages for text manipulation. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-OT/message.cfm/messageid:621 Subscription: http://www.houseoffusion.com/groups/CF-OT/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.29 |
|
|
Re: Text search and replace in column delimitated text files.Do you mean comma delimited records?
Try this: (syntax not exact - but you get the idea) Import the records into a table mytable <cfquery name="FixRecords> , select fieldtochange from mytable </cfquery> <cfoutput query="FixRecords> <cfif mid(FixRecords.fieldtochange,4,2) eq "08"> <cfset newstring = left(string, 3) & "42" & right(string, 6, (len(string)-5)> </cfif> <cfif mid(newstring,29,2) eq "08"> <cfset newstring = left(newstring, 28) & "42" & right(newstring, 31, (len(string)-30))> </cfif> <cfif mid(newstring,60,2) eq "08"> <cfset newstring = left(newstring, 59) & "42" & right(newstring, 62, (len(string)-61))> </cfif> <cfif mid(newstring,153,2) eq "08"> <cfset newstring = left(newstring, 152) & "42" & right(newstring, 155, (len(string-154))> </cfif> <cfquery name="updateRecord"> update Mytable set Fixedrecord = #newString#> </cfquery> </cfoutput> On Tue, Mar 25, 2008 at 10:21 AM, Ian Skinner <HOF@...> wrote: > I have text files that contain a several hundred to thousands of column > delimitated records. I need to replace a two digit year value from 08 > to 42 in four places in each record at characters 4 and 5; 29 and 30; 60 > and 61; as well as 153 and 154. Anybody have a quick how-to to > accomplish this? I have never done this type of large search and > replace where the only unique identifier of the data is it's position in > the string. > > Any creative ideas on a way to do this without writing a large string > processor to loop over all the records doing several string chopping and > concactination operations? I have available to me the default Windows > XP Professional and Windows Office 2000 programs, Dreamweaver and > Crimson Editor as well as Java, Perl and ColdFusion programming > languages for text manipulation. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;192386516;25150098;k Archive: http://www.houseoffusion.com/groups/CF-OT/message.cfm/messageid:622 Subscription: http://www.houseoffusion.com/groups/CF-OT/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.29 |
| Free Forum Powered by Nabble | Forum Help |