I have the following file:
cat file.txt
1/1 2/3
2/3 1/3
./2 1/1
./. 3/2
1/1 ./.
I would like to remove the dots and add the numbers from each column (delimited by a slashe and a space).
So far, I have:
fp = open("file.txt","r")
for line in fp:
cols = line.rstrip().split(" ")
res = [int(cols[i][0]) for i in range(0,len(cols))].remove('.')
print(sum(res))
I am trying to add the numbers before and after forward slash '/' in each column and output those delimited by '/'.
The expected output would be
4/7 7/9
Just one comment, the real file I'm working off of has more than 500 of these space delimited columns.