Find min, max, and average

October 25, 2011 at 14:06:05
Specs: Win 7 Ultimate , 4.17Ghz 8GB ram
I have a machine that out puts this data

4.480, 16.5
4.480, 16.6
4.480, 16.7
4.480, 16.8
4.480, 16.9
4.480, 17.1
4.480, 17.2
4.900, 17.3
4.900, 17.4
4.900, 17.5
4.900, 17.6
4.900, 17.7
4.900, 17.8
4.900, 17.9
4.900, 18.0
4.900, 18.1
4.900, 18.2
4.900, 18.3
5.290, 18.4
5.290, 18.5
5.290, 18.6
5.290, 18.7
5.290, 18.8
5.290, 18.9
5.290, 19.0
5.290, 19.1
5.290, 19.2
5.290, 19.3
5.290, 19.4
5.630, 19.5
5.630, 19.6
5.630, 19.7
5.630, 19.8
5.630, 19.9
5.630, 20.0
5.630, 20.1
5.630, 20.2
5.630, 20.3
5.630, 20.4
5.630, 20.5
5.900, 20.6
5.900, 20.7
5.900, 20.8
5.900, 20.9
5.900, 21.0
5.900, 21.1
5.900, 21.2
5.900, 21.3
5.900, 21.4
5.900, 21.5
5.900, 21.6
6.110, 21.7
6.110, 21.8
6.110, 21.9
6.110, 22.0
6.110, 22.1
6.110, 22.2
6.110, 22.3
6.110, 22.4
6.110, 22.5
6.110, 22.6
6.110, 22.7
6.110, 22.8
6.270, 22.9
6.270, 23.0
6.270, 23.1
6.270, 23.2
6.270, 23.3
6.270, 23.4
6.270, 23.5
6.270, 23.6
6.270, 23.7
6.270, 23.8
6.270, 23.9
6.400, 24.0
6.400, 24.1
6.400, 24.2
6.400, 24.3
6.400, 24.4
6.400, 24.5
6.400, 24.6
6.400, 24.7
6.400, 24.8
6.400, 24.9
6.400, 25.0
6.400, 25.1
6.500, 25.2
6.500, 25.3
6.500, 25.4
6.500, 25.5
6.500, 25.6
6.500, 25.7
6.500, 25.8
6.500, 25.9
6.500, 26.0
6.500, 26.1
6.580, 26.2
6.580, 26.3
6.580, 26.4
6.580, 26.5
6.580, 26.6
6.580, 26.7
6.580, 26.8
6.580, 26.9
6.580, 27.0
6.580, 27.1
6.580, 27.2
6.580, 27.3
6.650, 27.4
6.650, 27.5
6.650, 27.6
6.650, 27.7
6.650, 27.8
6.650, 27.9
6.650, 28.1
6.650, 28.2
6.650, 28.3
6.650, 28.4
6.710, 28.5
6.710, 28.6
6.710, 28.7
6.710, 28.8
6.710, 28.9
6.710, 29.0
6.710, 29.1
6.710, 29.2
6.710, 29.3
6.710, 29.4
6.710, 29.5
6.750, 29.6
6.750, 29.7
6.750, 29.8
6.750, 29.9
6.750, 30.0
6.750, 30.1
6.750, 30.2
6.750, 30.3
6.750, 30.4
6.750, 30.5
6.750, 30.6
6.790, 30.7
6.790, 30.8
6.790, 30.9
6.790, 31.0
6.790, 31.1
6.790, 31.2
6.790, 31.3
6.790, 31.4
6.790, 31.5
6.790, 31.6
6.790, 31.7
6.730, 31.8
6.830, 31.9
6.830, 32.0
6.830, 32.1
6.830, 32.2
6.830, 32.3
6.830, 32.4
6.830, 32.5
6.830, 32.6

i want to find the max min and average of the left column

Im wondering what the easiest way to do this is.

thank you


See More: Find min, max, and average

Report •


#1
October 25, 2011 at 15:13:58
Depending on how the data is output you create a loop that loops through each data item.

This could be a for/Next loop of a While/Wend loop.

Inside the loop you have three variable, Min,Max and Avg.

Each time through the loop you do a calculation.

If Max < Number then Max = Number
If Min > Number then Min = Number
Avg = Avg + Number

At the end of the loop you have the Minimum and Maximum.

You divide Avg by the number of times through the loop and you have the average. You will have to initialise Min with a number greater than any possible number that you want to know the minimum off.. 999 should do it.

Stuart


Report •

#2
October 25, 2011 at 15:25:15
Can you make up something real quick or and example that i can edit.

The left column is the output and the right is the time. I just took a segment of the output file

how do I isolate the left column?


Report •

#3
October 25, 2011 at 15:45:54
That depends on what programming language you are proposing to use. .

You have all the information you need if you apply yourself to it. You have had more help than most get for their homework questions.

All programming languages have some method of isolating comma separated values.

Stuart


Report •

Related Solutions

#4
October 26, 2011 at 12:12:13
I am going to be using windows batch scripting.

This is not for a school assignment it is for a machine that tests how much force something takes till it breaks

Note the machine is running windows 95


Report •

#5
October 27, 2011 at 03:58:33
Sorry, I cannot do Batch scripting. The last time I wrote any batch code was under Windows 3.11

Stuart


Report •

#6
October 27, 2011 at 06:07:02
Note the machine is running windows 95
It's been a long time since I wrote a batch file for anything DOS biased, but I'm pretty sure the logic you want isn't possible with the Win9X line (without writing a program though DEBUG). VBScript might be a better option.

How To Ask Questions The Smart Way


Report •

#7
October 27, 2011 at 08:26:56
Would a machine that old recognize vb script?

I would use that but I wasnt sure if it would work.


Report •

#8
October 27, 2011 at 09:57:34
Well sure. WSH was included with Win98, but I believe IE would upgrade the VBS engine as it was upgraded. (I might be mistaken on that part.) I'm not sure which COM objects and functions you'll have available, but you should have something.

How To Ask Questions The Smart Way


Report •

#9
October 27, 2011 at 10:27:10
Yeah sorry about he 2 similar threads.

I under stand what stuart is saying and I knew thats what I need to do but how do i code that out.

Im fluent in batch scripting except for the for loops and tokes. Thats why I came here to further my knowledge a little bit.

Can you point me in the right direction and I should be able to come up with something

The main thing is how to isolate the 2 columns and how to tell it to look at each line as a data point


Report •

#10
October 27, 2011 at 10:31:41
If it's Win95, you do not have access to the advanced FOR loop text parsing. Sorry.

How To Ask Questions The Smart Way


Report •

#11
October 27, 2011 at 11:01:43
Hmm ok

Any way that you know of to do it in vb script


Report •

#12
October 28, 2011 at 05:22:53
If VBScript isn't an option, you need to either look at writing a program, or installing a scripting language.

Const filePath = "a.txt"

Set fso = CreateObject("Scripting.FileSystemObject")
min = &H7FFFFFFF : max = 0 : total = 0
With fso.OpenTextFile(filePath)
  Do Until .AtEndOfStream
    line = .ReadLine
    If InStr(line, ",") Then
      line = CDbl(Trim(Split(line, ",")(0)))
      If line < min Then min = line
      If line > max Then max = line
      total = total + line
      count = count + 1
    End If
  Loop
End With
WScript.Echo "Min: " & min _
  & vbNewLine & "Max: " & max _
  & vbNewlIne & "Average: " & total / count

How To Ask Questions The Smart Way


Report •


Ask Question