python - Only the first digit of my data gets put in an array -
import numpy np import asciidata def leesdata(): ra = [] dec = [] data = asciidata.open('s0-2.txt') in data[1]: ra.append(float(i)) in data[2]: dec.append(float(i)) return ra, dec ra, dec = leesdata() print ra, dec
when run this:
[-0.04] [0.15, 0.138, 0.124, 0.098, 0.088, 0.078, 0.05, 0.041, 0.02, 0.01, -0.017, -0.004, 0.011, 0.072, 0.079, 0.085]
so first number of data gets put in array ra, dec works fine. doing wrong?
here file i'm trying open
normally i'd use combination of open , read this. here's how i'd read in file:
f = open('s0-2.txt', 'r+') ra = [] dec=[] line in f: if ( not(line.startswith('#')) ): ra.append( line.split()[1] ) dec.append( line.split()[2]) print ra print dec