Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How to read only specific, needed values from a csv file into python with genfromtxt?

lucknlovelucknlove DelhiMember Posts: 1

A python newbie with a large no of files and importing them. Each file contains some different values. Here is the code.

data = glob.glob('*.csv')
variance_data = []

for one_file in all_files:
try:
    with open(one_file) as data:
        all_data = np.genfromtxt((line.replace(',','.') for line in data),skip_header=9,delimiter=";")
except ValueError: 
    with open(one_file) as data:
        all_data = np.genfromtxt((line.replace(',','.') for line in data),skip_header=17,delimiter=";")

variance_data.append(np.nanvar(all_data))

I need to exclude all values from all files which are under some specific statistics. How can I deal with this? I guess there's an easy way which I still don't know. Thanks for any help!

Regards,
Lucky chaudhary
https://www.calipus.in

Sign In or Register to comment.