How to count numbers in a list from a csv file filtering out words and commas
Question: So im fairly new to python and im looking to do a few things:

  1. Display the number of numbers in the row
  2. Display the average of the numbers in the row
  3. Display the name of the row
  4. No use of libraries such as import csv

the raw csv file has 3 rows

    
    
    TTT TTTT, 21.72, 29.3, 20.08, 29.98, 29.85
    DDDD, 57.51, 47.59
    WWWW, 75.0, 82.43, 112.11, 89.93, 103.19, 80.6, 89.93, 103.19, 8
    

I have been at this for hours now and i simply can't get it my best attempt is
the following

    
    
    with open('test1.csv', newline='') as f:
        content = f.readlines()
        print (content)
        for line in content:
            entry = line.split(',')
            entry = line.split()
            print (entry)
            nums = 0
            list1avg = 0
            list1=[]
            for c in entry:
                if is_number(c):
                    print ("is num "+c)
                    list1.append(c)
                    nums+=1
                else:
                    print(c)
            for i in list1:
                list1avg = list1avg +1
            print(list1avg)
            print(nums)
            print("The average is "+list1avg/nums)
        print("Total numbers in this row is " +nums)
    

i know its a mess but any help is appreciated.


Answer: just to get the number of numbers and the row, you could do something like
this

    
    
    with open("csv_exmp.csv") as f:
        items = [line.strip().split(',') for line in f]
        for item in items:
            numerbs_amount = sum(map(is_number, item))
            print numerbs_amount, " in row:", item[0] 
    

if you want to count the average etc. just store the data in some variables
outside of the for-loop

