python - remove symbols from string -


i have file like:

@hwi abcde + @hwi7 efsa + ???=af gtey@jf gvtawm 

i want keep strings ( remove contains symbol )

i tried :

import numpy np arr = np.genfromtxt(f, dtype=str)  line in np.nditer(arr):     if np.core.defchararray.isupper(line) , not '@?=;?+' in line:         print line 

but gives :

@hwi abcde @hwi7 efsa ???=af gtey@jf gvtawm 

and expecting:

abcde efsa gvtawm 

i want use numpy , not commands regex or similar.

this solution :

import numpy np  arr = np.genfromtxt('text.txt', dtype=str)  test = np.core.defchararray.isalpha(arr) #create mask : true = str , false = not str  print arr[test] #use mask on arr , print values 

don't use if numpy ! have indexing ;)

i :

['abcde' 'efsa' 'gvtawm'] 

Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -