The script that reads a data file and stores its contents in an array. First data file row is a description of the fields, then the data is divided into two rows. (Using pure Python)
# Funtion to open and read input file def extract_data(filename): infile = open(filename, 'r') # open input file to read infile.readline() #first line does not contain data x_values = [] # declare empty arrays to store data y_values = [] for line in infile: words = line.split() #split lines into words x_value = float(words[0]) # cast first component of words from string to float y_value = float(words[1]) # cast second component of words from string to float x_values.append(x_value) y_values.append(y_value) infile.close() return x_values, y_values # Test function X, Y = extract_data('data_file.dat') print 'x values: ', X print 'y values: ', Y