I have a txt file with these characters: á é í ó ú ñ
and I want to make it a numpy array with np.genfromtxt
and when doing it, it displays this error:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 34: ordinal not in range(128)
If I open the file manually with a text editor and search and replace these characters á é í ó ú ñ with this ones a e i o u n, It works perfectly. But, I cannot mess with the data, the array has to be exact with the correct characters. Any ideas will help thanks.
mydata = np.genfromtxt("data.txt",delimiter=[4,2,2,2,2,2,2,2,2,236],dtype=[np.int16,np.int8,np.int8,np.int8,np.int8,np.int8,np.int8,np.int8,np.int8,(np.str_,236)],names=["a","b","c","d","e","f","g","h","i","j"])
It seems np.genfromtxt uses 'ascii' but I need it to use utf-8 for it to be compatible with the tilde symbols.