Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

# Thread: simple data parsing and analysis

1. ## simple data parsing and analysis

Thank you very much for your help. I've got a text file with the following
numbers displayed as such:
10 15
20 25
25 30

I would like to have output that looks like this:
10
20
25
Ave. = 18.33

15
25
30
Ave. = 23.33

I've tried a number of different angles with no luck. All help would be
appreciated tremendously!

• Showing us what you have so far would've been better because we could just edit your code instead of having to come up with an entirely new one. I'm just going to give you the algorithm for what to do and hopefully you'll be able to do it.

Start off by setting something like \$sum1, \$sum2, and \$count all equal to 0. Then also create two arrays \$vals1 and \$val2 with nothing in them. Obviously, you've got to read the contents of the file line by line. And when you get the contents of each line, you need to split it into two different variables with the split command. Add the first variable into \$sum1 using the .= notation and add the second variable into \$sum2. Then add the first variable into the current slot of the array (\$vals1[\$count] = \$variable1) and do the same for the second variable. Then increment \$count (\$count++). You do this all inside the looping structure you use to read the contents of the file. Then after that dive the sum variables by \$count and you have \$av1 and \$av2. Then just loop through each array (\$vals1 and \$vals2) displaying what's in each cell and then display the average at the end.

Does that help you out. I guess I could give you some actual code, but it'd probably be more beneficial for you if you can figure it out the rest on your own.

• ## thanks!

I'll try it out. I really appreciate your help. Next time, I'll include code, too!

•

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•