Revision | dd33bff1ad7427d901c06fdd5e2ae13ae4e7eadc (tree) |
---|---|
Zeit | 2009-01-19 23:55:24 |
Autor | iselllo |
Commiter | iselllo |
This file reads a two-column csv file where the first column is given by a list of the names of the
physical parameters, while the second list is the list of parameters themselves.
@@ -0,0 +1,48 @@ | ||
1 | +#! /usr/bin/env python | |
2 | +import scipy as s | |
3 | +import csv | |
4 | + | |
5 | + | |
6 | +def read_input(filename): | |
7 | + | |
8 | + | |
9 | + param_name_list=[] | |
10 | + param_value_list=[] | |
11 | + | |
12 | + | |
13 | + | |
14 | + reader = csv.reader(open(filename, 'r'), delimiter = ',') | |
15 | + line = 0 | |
16 | + IndexHeader = reader.next() | |
17 | + line = line+1 | |
18 | + for line in reader: | |
19 | + #print line | |
20 | + param_name, param_value = line[0], line[1] | |
21 | + | |
22 | + param_name_list.append(param_name) | |
23 | + param_value_list.append(float(param_value)) | |
24 | + | |
25 | + | |
26 | + | |
27 | + #print "param_name_list is, ", param_name_list | |
28 | + #print "param_name_list is, ", param_value_list | |
29 | + | |
30 | + param_arr=s.asarray(param_value_list) | |
31 | + | |
32 | + #print "param_arr is, ", param_arr | |
33 | + | |
34 | + #print "param_name_list[2] is, ", param_name_list[2] | |
35 | + | |
36 | + return param_arr | |
37 | + | |
38 | + | |
39 | + | |
40 | + | |
41 | + | |
42 | + | |
43 | + | |
44 | +input_arr=read_input("input.csv") | |
45 | + | |
46 | +print "input_arr is, ", input_arr | |
47 | + | |
48 | +print "So far so good" |