- Feb 13, 2003
- 13,295
- 118
- 106
I need a program to read through a text file and make changes upon certain conditions and spit out a new file. Here is the example below.
Take this text file
And make it look like this:
Basically it must search the values in the quotations and make necessary changes to the code in the quotations and add a BEG *** command above where the code is B **and an END command after (providing the next code in the quotation is not the same value.) And if there is another code of the same value a few lines down, it must add the CONT *** command above it.
When there is a B *** code in the quotations, it must also remove the B and the space in the portion within the quotations.
Is this doable with relative ease?
Take this text file
NEZ 13000 4860271.330 683259.150 92.391 "DCB"
NEZ 13001 4860271.057 683258.136 92.418 "B GO"
NEZ 13002 4860260.096 683260.271 92.683 "GO"
NEZ 13003 4860293.237 683255.697 92.738 "GO"
NEZ 13004 4860318.665 683253.699 92.434 "GO"
NEZ 13005 4860319.888 683255.541 92.423 "CB"
NEZ 13006 4860327.588 683250.237 92.557 "B EP"
NEZ 13007 4860332.990 683248.822 91.965 "B BD"
NEZ 13008 4860338.890 683270.007 91.919 "BD"
NEZ 13009 4860333.877 683272.528 92.534 "EP"
NEZ 13010 4860324.544 683274.007 92.337 "GO"
NEZ 13011 4860296.177 683276.034 92.416 "GO"
NEZ 13012 4860272.743 683277.075 92.369 "GO"
NEZ 13013 4860263.201 683277.590 92.347 "B EP"
NEZ 13014 4860260.877 683277.765 92.429 "B GO"
NEZ 13015 4860262.766 683301.026 92.175 "GO"
NEZ 13016 4860264.814 683300.366 92.038 "EP"
NEZ 13017 4860274.145 683299.075 92.101 "GO"
And make it look like this:
NEZ 13000 4860271.330 683259.150 92.391 "DCB"
BEG GO
NEZ 13001 4860271.057 683258.136 92.418 "GO"
NEZ 13002 4860260.096 683260.271 92.683 "GO"
NEZ 13003 4860293.237 683255.697 92.738 "GO"
NEZ 13004 4860318.665 683253.699 92.434 "GO"
END
NEZ 13005 4860319.888 683255.541 92.423 "CB"
BEG EP
NEZ 13006 4860327.588 683250.237 92.557 "EP"
END
BEG BD
NEZ 13007 4860332.990 683248.822 91.965 "BD"
NEZ 13008 4860338.890 683270.007 91.919 "BD"
END
CONT EP
NEZ 13009 4860333.877 683272.528 92.534 "EP"
END
CONT GO
NEZ 13010 4860324.544 683274.007 92.337 "GO"
NEZ 13011 4860296.177 683276.034 92.416 "GO"
NEZ 13012 4860272.743 683277.075 92.369 "GO"
END
BEG EP
NEZ 13013 4860263.201 683277.590 92.347 "EP"
END
BEG GO
NEZ 13014 4860260.877 683277.765 92.429 "GO"
NEZ 13015 4860262.766 683301.026 92.175 "GO"
END
CONT EP
NEZ 13016 4860264.814 683300.366 92.038 "EP"
END
CONT GO
NEZ 13017 4860274.145 683299.075 92.101 "GO"
END
Basically it must search the values in the quotations and make necessary changes to the code in the quotations and add a BEG *** command above where the code is B **and an END command after (providing the next code in the quotation is not the same value.) And if there is another code of the same value a few lines down, it must add the CONT *** command above it.
When there is a B *** code in the quotations, it must also remove the B and the space in the portion within the quotations.
Is this doable with relative ease?
Last edited: