I'm trying to write a program that will open a file named "data.dat". This file contains an unknown number of values that I need to have read and averaged together and is written such that each line has one value. I need to have the data in this file be averaged and printed to the screen. I'm having trouble just getting started with this and any help would be appreciated. Thanks
dmcadidas15
0
Newbie Poster
Recommended Answers
Jump to Posthi,
here's a small example on opening and reading from a file.Suppose you have a file "data.dat" containing the numbers from 1 to 7 like this
1
2
3
4
5
6
7f = open( "data.dat", "r" ) lines = f.readlines() # returns every …
All 3 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.