1
#=========================================================================
2
# NAME: read_array_demo1
4
# DESCRIPTION: Examples to read 2 columns from a multicolumn ascii text
5
# file, skipping the first line of header. First example reads into
6
# 2 separate arrays. Second example reads into a single array. Data are
9
# Here is the format of the file test.txt:
18
# python read_array_demo1.py
27
# AUTHOR: Simon J. Hook
30
# MODIFICATION HISTORY:
34
#============================================================================
37
from scipy.io import read_array
42
# First example, read first and second column from ascii file. Skip first
44
# Note use of (1,-1) in lines to skip first line and then read to end of file
45
# Note use of (0,) in columns to pick first column, since its a tuple need trailing comma
46
x=read_array("test.txt",lines=(1,-1), columns=(0,))
47
y=read_array("test.txt",lines=(1,-1), columns=(1,))
49
#Second example, read the file into a single arry
50
z=read_array("test.txt",lines=(1,-1), columns=(0,2))
53
plot(x,y,'r--',z[:,0],z[:,1])
56
# The one and only main function
57
if __name__ == "__main__":