I'm trying to process a tab-separated table in which some of the cells have line-wraps. The tables were extracted from PDF tables automatically and look like this:
1 UNITED STATES OF 3797
AMERICA
2 CANADA 3855
3 ISLAMIC REPUBLIC 636
OF IRAN
where the left-hand column in each text line has an entry only if the line actually starts a new data entry. (I've used spaces to simulate the effect of tab-spacing because StackOverflow won't allow me to input tabs.) I'd like to find some simple way to transform this table into the following, ideally with line-oriented Unix text-processing tools:
1 UNITED STATES OF AMERICA 3797
2 CANADA 3855
3 ISLAMIC REPUBLIC OF IRAN 636
Is there an easy way to do this with the standard Unix tools? I've experimented a bit and haven't found one.