Filling space/tab separated, empty columns with 0

前端 未结 5 2006
天命终不由人
天命终不由人 2021-01-07 02:06

i have a huge file and as an output some columns doesn\'t have a value, i need to fill these columns with 0 for further analysis. I can separate the columns with space or ta

5条回答
  •  一生所求
    2021-01-07 02:34

    Deleting my answer after re-reading the original post. There are no tabs as data, just delimeters. If there is no data, a double delimeter will apear to align the columns.
    It can't be any other way. So if a single delimeter is there, it will separate two empty fields. "" = 1 empty field, "\t" = 2 empty fields. I got it now.

    Tim Pietzcker has the correct answer all along. +1 for him.
    It could be written alternatively as s/ (?:^|(?<=\t)) (?=\t|$) /0/xg;, but its the same thing.

提交回复
热议问题