Search code examples
pythonnotepad++text-processing

convert multiple columns vertical text to horizontal


I tried these, but its only for one column. using notepad++ and python. Any solution that can do for multiple columns of text?

# Input:
tim
oso
d n
a d
y a
  y

# Output:
today 
is 
monday

Solution

  • You can do this fairly easily with a loop, something like:

    s = "tim\noso\nd n\na d\ny a\n  y"
    bits = s.split('\n')
    lines = ['' for i in range(0, len(bits[0]))]
    for bit in bits:
      for i in range(0, len(bit)):
        if bit[i] != ' ':
          lines[i] += bit[i]
    '\n'.join(lines)