Friday, 15 March 2013

string - Skipping over array elements of certain types -



string - Skipping over array elements of certain types -

i have csv file gets read code arrays generated out of each row of file. want ignore array elements letters in them , worry changing elements containing numbers floats. how can alter code this:

myvalues = [] info = open(text_file,"r") line in data.readlines()[1:]: myvalues.append([float(f) f in line.strip('\n').strip('\r').split(',')])

so lastly line knows seek converting numbers floats, , skip letters entirely?

put way, given list,

list = ['2','z','y','3','4']

what command should given code knows not seek converting letters floats?

you utilize try: except:

for in list: try: myval.append(float(i)) except: pass

string python-2.7 floating-point

No comments:

Post a Comment