How can I save a 2-dimensional array into a text file with python? I tried to do it as follows, but I get an error:
readcodon= open("codon.txt","r")
triplets=readcodon.read().split()
for i in range(0,len(triplets)):
A=np.array(triplets, dtype=None)
readcodon.write(A)
This is the error message:
readcodon.write(A)
TypeError: write() argument must be str, not numpy.ndarray
Here is a sample of codon.txt:
TTT TCT TAT TGT TTC
The expected output in the file text:
[TTT, TCT, TAT, TGT, TTC ]