Skip to main content
1-Visitor
July 8, 2013
Solved

Data import a file based on a programme variable

  • July 8, 2013
  • 2 replies
  • 3977 views

(This is for V14 M030 (or V11.2a))

I'm looking for the workaround to allow the data import component to allow the file name for import to be selected programmatically. The basic wizard requires one to set the filename, and to edit it via the right click properties.

A colleague has been tasked with auto processing ~50 different data sets, so doing it by hand is not really a sensible solution. (One of the issues is the data file also has some columns which are hex data, so we need the general data entry, and then post proces it once it's inside mathcad, or use matlab (not as nice)

I'm sure there was a work around I Just can't find it at the moment. Anyone remember how to do it?

Philip

Best answer by Werner_E

It depends on how the component, or better which component is inserted.

If you use "Insert/Data/File Input" the filename can only be changed by using the properties menu (or possibly via script.

But if you use "Insert/Data/Data Import Wizard" or "Insert/Component/Data Import Wizard" you can add exactly one Input Variable and that is taken automatically as the path/filename.

2 replies

25-Diamond I
July 8, 2013

Not sure if this would suffice, but if you insert a table using the wizard you can right click and then chose "Add Input variable". This field would be taken as filename and accepts a Mathcad string variable, so I guess you can make it a function with that input variable as parameter.

1-Visitor
July 9, 2013

Many of the components don't appear to allow the 'add input variable', and then there is the problem of associating the variable with the place the component reads the filename from. It appears quite tricky.

Werner_E25-Diamond IAnswer
25-Diamond I
July 9, 2013

It depends on how the component, or better which component is inserted.

If you use "Insert/Data/File Input" the filename can only be changed by using the properties menu (or possibly via script.

But if you use "Insert/Data/Data Import Wizard" or "Insert/Component/Data Import Wizard" you can add exactly one Input Variable and that is taken automatically as the path/filename.

19-Tanzanite
July 8, 2013

Could you do it with a script?

1-Visitor
July 9, 2013

I've got the basics for a script that could be adapted, but sometimes one wants to avoid inflicting additional VBscripting tasks on the users (and the debugging hassle).

It would be good if the data import function could take a format string so that it could cope with different separators, hex data, and ignorable columns 😉 But you can't have everything when you are waiting for prime time.

19-Tanzanite
July 9, 2013

I've got the basics for a script that could be adapted, but sometimes one wants to avoid inflicting additional VBscripting tasks on the users (and the debugging hassle).

I would always want to avoid it. Unfortunately, Mathcad's file handling has never been as versatile or complete as needed, so sometimes there is no choice.

It would be good if the data import function could take a format string so that it could cope with different separators, hex data, and ignorable columns 😉 But you can't have everything when you are waiting for prime time.

We can't even have the things we already have