input.txt is tab-delimited.
I know a simple code to replace.
import fileinput
for line in fileinput.FileInput("input.txt",inplace=1):
line = line.replace("AA","0")
print line,
However, I want to replace cells of only the 3rd column of input.txt (not the whole file input.txt), and I want to replace a cell by 0 if it is any one of AA or AAA or BB or BBB, replace a cell by 1 if it is not any one of them.
Here, I am talking about "Match entire cell contents"
By "Match entire cell contents" I mean that, it will be replaced only when a cell (such as (2,3)-element of input.txt) is exactly AA or AAA or BB or BBB. A cell such as "AAs" will not be replaced by anything.
On the contrary if "Match entire cell contents" is not applied, then it will be replaced whenever a cell merely "contains" AA or AAA or BB or BBB. So a cell "AAhaha" will be replaced by "0haha"
Anyhow, to repeat, I want to replace cells of only the 3rd column of input.txt (not the whole file input.txt), and I want to replace a cell by 0 if it is any one of AA or AAA or BB or BBB, replace a cell by 1 if it is not any one of them, in a "Match entire cell contents" way.