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
If you are using a method to normalise the file content so that it will become a tab-separated value (tsv) file, than you can do something like this:

```
def normalise(lines, max_num_of_columns=None):
    if max_num_of_columns == None:
       max_num_of_columns = max({len(line.split('\t')) for line in lines})
    for line in lines:
        content = line.split('\t')
        while len(content) < max_num_of_columns:
            content.append('')
        print '\t'.join(content)

lines = ['A\tB\tD\nC','K\ts']

normalise(lines)
...
A   B   D
C
K   s   

```

If you don't know the max\_num\_of\_columns you have to check the file first (see the first if).