I am a newbie in python programming. I am reading a tab separated file and would like to do an operation which can replace multiple tabs (separating two columns) by single tab.
with open('file.tsv','r') as fin:
cr = csv.reader(fin, delimiter='\t')
filecontents = [line for line in cr]
I tried doing it by join function
with open('file.tsv','r') as fin:
cr = csv.reader(fin, delimiter='\t')
filecontents = ''.join([line.replace('\t\t', '\t') for line in cr])
I am getting below error.
AttributeError: 'list' object has no attribute 'replace'
How can I do it?