Reputation: 183
I am not a programmer, I am new to python, and I have a lot of difficulty with text files.
The columns are in a text file (.txt space delimited). Can I replace the values in the second column (DLT) with the values that I have in a numpy array?:
JDAY DLT ELWS T2
4.0 5.0 6.0 7.0
3.0 4.0 5.0 6.0
3.0 5.0 7.0 6.0
data=np.array([6.0,3.0,4.0])
I can take the values from that column with this:
getvalues = np.genfromtxt('file.txt', skip_header=2, names=True)
val=getvalues['DLT']
I have been reading a lot of examples but I can´t find a solution.
Upvotes: 0
Views: 87
Reputation: 19547
You should just be able to write:
getvalues['DLT'] = data
The caveat here is getvalues['DLT']
must be equal in length to data
.
Upvotes: 2