2021年3月30日星期二

Find the minimum between two consecutive occurrence of numbers and repeat the process to the end of the file

Having a 0.txt file below:

Report "Curve ABC" for bread and milk on 03/03/1999, New Mexico City:    Bread and mil price by markets:    milk on market "Onlyfoods"  10  bread on market "Onlyfoods"  23  milk on market "spassus"  30  bread on market "spassus"  4  bread on market "chaim"  56  milk on market "chaim"  96  bread on market "house green"  7  milk on market "house green"  0.8  

I would like to compare the first line where there are any number with the second consecutive line where there are also some number, and then determine the minimum value between them and print the number of the line where the minimum value is. I would like to repeat the same process for the third and fourth occurrence of some number, that is, compare them and get the minimum between them, and so on.

I have made a similar question but got many downvotes and I do not understand why this issue is not useful being that no one has shown me some other issue already posted here in the stackoverflow.

I could combine this issue, "calculate the difference between number lines file", with this question, Find the line with the min and max value and your line number from text file (Get Value Error Float Type), but I have not been able to understand how to do this.

EDIT UPDATE 1:

Alternative partial pseudocode:

A starting point using UNIX/REGEX/AWK: Basically I should: 1 - Extract the line number of each instance of numeric value and save to a 1.txt file in a list vertically; 2 - Extract the numeric value of each instance and save in 2.txt in a vertical list and then apply the solution given here to find the minimum between each pair of consecutive rows and save the minimum values (in order as extracted) in a file 3.txt; 3 - So I should append or paste on the left or right of each respective 1.txt line using a separator such as a comma or: each line of 3.txt and save in a 4.txt file.

https://stackoverflow.com/questions/66879803/find-the-minimum-between-two-consecutive-occurrence-of-numbers-and-repeat-the-pr March 31, 2021 at 07:41AM

没有评论:

发表评论