mfi = Multiple File Import(
<<Set Folder( "$SAMPLE_IMPORT_DATA" ),
<<Set Name Filter( "UN*.csv" ), // import files with this name
<<Set Name Enable( 1 ) // display the file name in a column
)
<<Import Data();
mfi holds the Multiple File Import object.
dtlist holds the list of files produced by sending the Import Data message to the MFI object. The MFI object is gone because it was not stored in a variable or window. You can keep the MFI object by sending Create Window to it or storing the object in a variable, such as mfi, and by sending messages such as Import Data to that variable.
Create Window can be useful for debugging. The window is visible and the MFI object is available. Run the following lines one at a time to see it:
mfi = Multiple File Import();
mfi <<Create Window;
mfi <<Set Folder( "$DESKTOP" );
The Import Data message always returns a list: an empty list for no files, a list of one data table for one file, a list of N data tables for many files. Here’s an example of using dtlist to get the first data table from the list and then formatting the third column with the thousands separator:
dtlist = Multiple File Import(
<<Set Folder( "$SAMPLE_IMPORT_DATA" ),
<<Set Name Filter( "UN*.csv" ), // import files with this name
<<Set Name Enable( 1 ) // display the file name in a column
)
<<Import Data();
dt = dtlist[1]; // get the first dt from the list
dt << Save( "$DESKTOP/example.jmp" );
Column( dt, 3 ) << Format( "Fixed Dec", Use thousands separator( 1 ), 13, 0 );
•
|
•
|
See Import Images from a Directory for details about using MFI to import images from a web page into a data table.
|