Question: This is a tab-delimited txt.

```
A    B    D
C
K    s

```

So there is nothing in (2,2), (2,3) (3,3) entry, NOT EVEN TAB.

The maximum length row is 1st row, and 1st row has 3 columns.

Can I simply add 2 tabs to 2nd row, 1 tab to 3rd row, so that this tab-delimited txt becomes a "square"?

**What I have tried**

1. Tried to use notepad++'s replace. 

Find what:(blank), Replace with: \t, Checked 'Match whole word only'.

It didn't work.

Find what:(blank), Replace with: \t, Regular expression

It didn't work.
2. Tried python

```
import fileinput
for line in fileinput.FileInput("input.txt",inplace=1):
    line = line.replace("",\t)
    print line,

```

It didn't work for this purpose.

Answer: 
Looks like you'll have to count the TAB occurences in each line and append n TABs.

However, if it's a one time task, MS Excel should help:

1. paste txt file content to worksheet
2. use data -> text to clumn
3. extract the "square" range -> excel should fill up the required TABs
Pretty ugly and inefficient, but I found this gets the job done:

```
myStr = "A\tB\tD\nC\nK\ts"

maxLen = max([len(line.split('\t')) for line in myStr.split('\n')])

newstr = ''.join([line + ('\t' * (maxLen - len(line.split('\t')))) + '\n' for line in myStr.split('\n')])

>>> newstr
'A\tB\tD\nC\t\t\nK\ts\t\n'

```

might have to be modified a bit depending on how your input looks, how you're handling newlines, etc. But I think that's the basic idea. You find the max length of a line and go through and make all your other lines that length by filling up with tabs.