I have a text file with rows, and columns within those rows. I want to, essentially, replicate the Excel "fill down" function. In other words, if there is a blank "cell" on a line, it will look to the line above it and fill down the value in the corresponding field above it. Example, with "^" being used as column separator:
London^Paris^Moscow^Berlin ^^Melbourne^New York^Washington ^^^Sydney^Singapore^New Delhi ^^New York^Washington Kuala Lumpur^Bangkok^Hong Kong ^^^^Johannesburg^Sydney^Singapore^New Delhi Amsterdam ^^Bucharest
... becomes (filled down items in CAPS for clarity):
London^Paris^Moscow^Berlin LONDON^PARIS^Melbourne^New York^Washington LONDON^PARIS^MMELBOURNE^Sydney^Singapore^New Delhi LONDON^PARIS^New York^Washington Kuala Lumpur^Bangkok^Hong Kong KUALA LUMPUR^BANGKOK^HONG KONG^^Johannesburg^Sydney^Singapore^New Delhi Amsterdam AMSTERDAM^^Bucharest
So essentially the function is to identify any blank field, and, where there is one, pull the value down from the corresponding field above it. Important to be able to specify the field/column separators. Any ideas ?