I have a csv that looks like below with up to 15000 lines.
The numeric values of Start and End are between 0 and 300.
I am looking for a way to parse through the file, search for rows starting with white, then check the Start value and the End value of this row with the following conditions:
- if the value ≤ 150 then add 150
- if the value is > 150 then subtract 150
Finally, overwrite the source file with the edits.
I am looking for a way to realize that with bash or python.
Any help is much appreciated!
Raw Data:
Color, Start, End
white, 0, 1,
black, 23, 150,
black, 150, 24,
white, 24, 152,
black, 152, 25,
black, 25, 154,
black, 154, 81,
white, 99, 220,
...
Final Data:
Color, Start, End
white, 150, 151,
black, 23, 150,
black, 150, 24,
white, 174, 2,
black, 152, 25,
black, 25, 154,
black, 154, 81,
white, 249, 70,
...