14,207,483 members
See more:
I have a CSV file separated by commas. I need to read the file, determine which lines contain a number that needs to be higher than a given number (say 711), and calculate the percentage of those numbers that fit the criteria.

What I have tried:

myfile = open('3517315a.csv','r')

myfilecount = 0

linecount = 0

firstline = True

for line in myfile:
if firstline:
firstline = False
continue
fields = line.split(',')

linecount += 1
count = int(fields[0])
colour = str(fields[1])
channels = int(fields[2])
code = str(fields[3])
correct = str(fields[4])

print( 'percentage of numbers greater than or equal to 711 is %d:')
Posted
Updated 23-Mar-17 9:06am
NotPolitcallyCorrect 23-Mar-17 15:06pm

Other than reposting this same thing over and over, what have you tried? Isn't calculating percentages like 4th grade math?

Solution 1

First, you need to make your mind, it is C or C# or Python, but not the 3, not even 2 of them.
Quote:
I need to read the file, determine which lines contain a number that needs to be higher than a given number (say 711), and calculate the percentage of those numbers that fit the criteria.

If you read the file on screen, how do you do to count the number of values that meet the criteria and what you need to get the percentage of values that meet the criteria ? The program will do the same.

Top Experts
Last 24hrsThis month
 OriginalGriff 80 Patrice T 50 Richard MacCutchan 40 Gerry Schmitz 40 W∴ Balboos 25
 OriginalGriff 2,030 Patrice T 676 Thomas Daniels 665 Richard MacCutchan 653 Dave Kreskowiak 505