# Interpolate specific columns of data

I have a txt file with 3 columns of data:

x y1 y2

How do I import the file then create 2 functions, one interpolated with {x,y1} values and the other interpolated with {x,y2} values?

This is the sort of thing I want to achieve (in pseudocode):

Import "data.txt" into A
f1 = Interpolation(A,{x,y1})
f2 = Interpolation(A,{x,y2})

-
Did you happen to look up the Import documentation? This and its subpage on basic formats (search for "Table") would be a good starter.Interpolation also has a very readable doc page. To get the table you obtain after importing into separate columns, you need Transpose. Please, try to reach a minimum proficiency level of the language by reading the documentation before asking questions. – Sjoerd C. de Vries Jun 22 '12 at 12:39
For taking parts of arrays you could check out the documentation of Part – Heike Jun 22 '12 at 12:45

Maybe something like

a = Transpose[Import["data.txt", "Table"]];

f1 = Interpolation[{a[[1]], a[[2]]} // Transpose];
f2 = Interpolation[{a[[1]], a[[3]]} // Transpose];


might work?

Alternatively,

a = Import["data.txt", "Table"];

f1 = Interpolation[Drop[#, {3}] & /@ a];
f2 = Interpolation[Drop[#, {2}] & /@ a];


or even

f1 = Interpolation[ a[[All, {1, 2}]] ];
f2 = Interpolation[ a[[All, {1, 3}]] ];

-
For the second one, you can also use a[[All,{1,2}]] and a[[All, {1,3}]] instead of Drop[...]&/@a. – Heike Jun 22 '12 at 12:42
Thanks, but only the first method worked for me – Eddy Jun 22 '12 at 13:25