Group Abstract Group Abstract

Message Boards Message Boards

0
|
5.6K Views
|
1 Reply
|
1 Total Like
View groups...
Share
Share this post:

Convert csv data into Interpolation input?

Posted 9 years ago

Hi,

After importing a CSV I have a list of coordinates/corresponding function values as {x, y, z, f(x,y,z)}, but Interpolation expects a list structured as {{x, y, z}, f(x,y,z)}. What is the easiest way to convert it to that format?

Thanks, Gijsbert

One method that is most general, and easy to see what is happening is:

newlist = {{#1, #2, #3}, #4}& @@@ oldlist;

But solutions with TakeDrop or Table and so on are also possible:

newlist = Table[{p[[;;3]], p[[4]]}, {p,oldlist}]
POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard