cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

How to insert data files in Mathcad 15 using a script

mzarrabi
12-Amethyst

How to insert data files in Mathcad 15 using a script

Hi all,

I am trying to read several .dat files from a certain folder by specifying the path in Mathcad 15.

I wonder if there is any script function to do that instead of inserting all the files one by one?

 

1 ACCEPTED SOLUTION

Accepted Solutions
LucMeekes
23-Emerald III
(To:mzarrabi)

Something like this:

LucMeekes_0-1603127060250.png

Success!
Luc

View solution in original post

7 REPLIES 7
ChrisKaswer
15-Moonstone
(To:mzarrabi)

If your files are sequential in their name - "data_1.dat", "data_2.dat", etc., you can write a program loop that will read the data from each file and place them all in a matrix. This approach worked very well for me.

 

Hope this helps!

Hi @ChrisKaswer. Thank you for your reply. Do you have a template to share?

LucMeekes
23-Emerald III
(To:mzarrabi)

Something like this:

LucMeekes_0-1603127060250.png

Success!
Luc

Yes - what Luc has shared is very similar to what I have implemented. You can get a bit more complicated by monitoring the size of any data file and reading files that have different row and column counts. Units can be read-in as well with some other tricks (of course the data needs to be set-up to accommodate this), but Luc has captured the fundamental approach well.

 

Good luck!

mzarrabi
12-Amethyst
(To:LucMeekes)

Thank you @LucMeekes for sharing that. That is very useful. 

mzarrabi
12-Amethyst
(To:LucMeekes)

Is there a way that we give the path and the file ext, and then Mathcad returns all the files having that ext? 

LucMeekes
23-Emerald III
(To:mzarrabi)

You mean like this:

LucMeekes_0-1603136980728.png

Sorry, only in Mathcad 11, not in Mathcad 15.

 

Luc

 

 

Top Tags