Message Boards Message Boards

0
|
6670 Views
|
6 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Reading from multiple data files

I want to program Mathematica 9 to read the coordinates (x,y,z) of a given object (which is characterized by a 7 digit number) from multiple files and make a plot. Is there a way to do this?

POSTED BY: Nilanjan Banik
6 Replies

There most likely is. What is the format of your files?

The function for you to read about is Import:

http://reference.wolfram.com/language/ref/Import.html

POSTED BY: David Reiss

The data are in .xsls format. However how do you get Mathematica to open multiple files whose names have a pattern like example. 01, example. 02 and so on.

POSTED BY: Nilanjan Banik

Nilanjan,

You can use * wildcard to import all files:

SetDirectory[NotebookDirectory[]] ;
(* export test files *)
Export["eg01.dat",1] ;
Export["eg02.dat",2] ;
Export["eg03.dat",3] ;
Export["eg10.dat",10] ;
(* import all test files *)
Import["eg*.dat"]?

I.M.

POSTED BY: Ivan Morozov

Thank you for your reply. I do know about the * wildcard, but what I don't know is how do I get Mathematica to plot the points of a given object from all these files. I am trying to get Mathematica to look for a given object whose ID is say 3456789, whose position is changing with time (redshift in my case) and to plot their position. The various files that I have stores the positions of these objects at a given redshift. I am trying to make 3 plots time vs X, time vs Y and time vs Z for the objects.

Thanks

POSTED BY: Nilanjan Banik

HI Nilanjan,

What is difficult about your question is that your are describing your files in general terms but not actually explaining their exact format. What you are asking for is completely doable but the details depend on the exact format of your data. Without that there isn't a way for someone to tell you what specific code to write to complete your task. Do you have a different file for each time? And, if so, then does each such file have two columns: redshift and position? And also, if so, is the time specified in the file's name or is it somehow in the file itself?

In any case it will help to give you some answers if you either (a) give a detailed specification of the files and the filenames and/or (b) give a set of example files.

I'm sure we'd all like to help, but we need your help with the actual details ;-)

Best, David

POSTED BY: David Reiss
POSTED BY: Nilanjan Banik
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract