Skip to main content
1-Visitor
November 1, 2012
Question

Questions about reading files in Mathcad

  • November 1, 2012
  • 1 reply
  • 5622 views

Hi,

I have a Mathcad 15 and I have a problem to read files that change the final part of their names but the beginning is always the same, what is the expression I use Mathcad to only recognize these files?

In batch we use the "*", but I'm struggling to find an operator in Mathcad to do the same function

1 reply

19-Tanzanite
November 1, 2012

If you go here: Extra Components.mcd there is a scripted component that will give you a list of files in a folder. Will that do what you want? If not, could you be more specific about the nature of the problem.

Iuri1-VisitorAuthor
1-Visitor
November 1, 2012

Richard thanks for the reply,

but what I want is simpler than that, I need to read files .dat that will be in the directory one at a time with the following structure: in_ [the date on which the file was generated].dat. Then read using any function of Mathcad I tried to write this file as in*.dat. But I do not know which operator can replace the "*" I've used.

23-Emerald IV
November 1, 2012

Hi Iuri,

There is no operator "*", unfortunately. It must be done the hard way.

As a possible alternative to Richard's suggestion, you can check to see if the function Files() works in your Mathcad 15 (In MathCad 11 it does).

This function accepts 2 arguments:

- a path, like "C:\"

- a file attribute, like "a".

But the second argument is optional.

So if it works in mathcad 15, the expression:

Files("C:\Windows","d")=

Should give you an array of strings, each string representing one of the subdirectories of C:\Windows

And with Files("C:\")=

you should get a list of all files on the root of drive C:

In order to find the "In_*.dat" file, you should parse the array, using MathCad's string functions.

Note that Files() is not documented (at least not in Mathcad 11) and/but works to some extent: it generally shows only files that do have an attribute (a,d,h,r,s). Fortunately new files usually have the "a" atribute set.

But all the above is of no use to you if the function is not supported by mathcad 15....

Success!

Luc