Hi guys,

I have a csv/text file with a bunch of numbers ranging from 500 to 500,000 and would like to replace the matches with a and mismatches by shifting the mismatched content to right simultaneously shifting the rest of the columns to right but leaving the top row untouched and then replacing the empty spaces in that column with b so that I have a

**fixed length matrix**, for instance, I have the following:

Code: Select all

```
12345,6457,789,21231,657
6457,21231,657
12345,789,21231
```

When I search for the string 12345 in the first column replace the matched cells (row 1 column 1 and row 3 column 1) with 1 and mismatched cell (row 2 column 1) with a 0 and comma after pushing the second row to the right..see below for the output:

Code: Select all

```
a,6457,789,21231,657
b,6457,21231,657
a,789,21231
```

Now when I search for the next string (6457) in the second column perform the same steps as above, that is, replace the matched cells (row 1 column 2 and row 2 column 2) with 1 and mismatched cell (row 3 column 2) with a 0 and comma after pushing the third row to the right ..see below for the output:

Code: Select all

```
a,a,789,21231,657
b,a,21231,657
a,b,789,21231
```

The final output after looking for 789, 21231 and then 657 should look something as below (a fixed length matrix):

Code: Select all

```
a,a,a,a,a
b,a,b,a,a
a,b,a,a,b,
```

See below for a link to the sample file:

https://pastebin.com/AmbHYC9T
Thanks

Plasma33