I have a file that i am looking to modify. There are 100's of files having the same issue. the input file is below
sample1 100A total 1 1000
sample2 100A total 1 5584
sample3 100A total 1 8125
sample4 100A total 1 59
sample1 . year 1 1000
sample1 . week1 20 1001
sample1 . week2 50 1001
sample2 . year 1 5584
sample2 . week1 20 5585
sample2 . week2 100 5585
sample3 . year 1 8125
sample3 . week1 55 8126
sample3 . week2 100 8126
sample4 . year 1 59
sample4 . week1 10 59
sample4 . week2 8 59
In the above file, where third column says "total" is the look up table and the maximum value for it should not exceed in any of the rows below for the respective samples.
For example, "sample1" has maximum value of 1000 but for "week1" and "week2" in third column has "1001" as maximum value. I see this happening for few rows for "week1 and week2" only and always its only 1 greater than maximum value. The output should be for both "week1" and "week2" rows should be updated to maximum value "1000". sample output below
sample1 100A total 1 1000
sample2 100A total 1 5584
sample3 100A total 1 8125
sample4 100A total 1 59
sample1 . year 1 1000
sample1 . week1 20 1000
sample1 . week2 50 1000
sample2 . year 1 5584
sample2 . week1 20 5584
sample2 . week2 100 5584
sample3 . year 1 8125
sample3 . week1 55 8125
sample3 . week2 100 8125
sample4 . year 1 59
sample4 . week1 10 59
sample4 . week2 8 59
Please provide me guidance on how should i proceed. I am a beginner programmer here looking to learn. thank you for your help
1
in the last character with a0
? if not then please update the question to show a more varied sample of data (both input and the expected output)