cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
david707
Level III

Problems working with data tables created by Multiple File Import

Hi,

Basically what I am trying to do is have a script that will run "Multiple file import" on several folders and concatenate the results into a single table. Here is my current script:

 

path = ""; // (actual folder path redacted, pretend something that works is here)
fid = Files In Directory(path);
// Remove all the files, just leaving the folders
for(f=NItems(fid), f>=1, f--, if(IsFile(path||"/"||fid[f]), RemoveFrom(fid, f)));
vn = 0;
print(N Items( fid ));
For( LV1 = 1, LV1 <= N Items( fid ), LV1++,
	print(LV1);
	If(
		contains(fid[LV1],"EU")
	,
		vn++;
		VAReus = contains(fid[LV1],"EU");
		STRrn = substr(fid[LV1],VAReus,9);
		show(fid[LV1],STRrn);
		STRfold = path||char(fid[LV1]);
		DT1 = Multiple File Import(
			<<Set Folder(
				STRfold
			),
			<<Set Name Filter( "*.jpg" ),
			<<Set Name Enable( 1 ),
			<<Set Size Enable( 0 ),
			<<Set Date Enable( 0 ),
			<<Set Add File Name Column( 0 ),
			<<Set Add File Size Column( 0 ),
			<<Set Add File Date Column( 0 ),
		) << Import Data;
		wait(0.1);
		DTT1 = DT1 << Transpose(columns(:Picture), Output Table("DTT1"), Link to original data table( 0 ));
		wait(0.1);
		try(Close(DT1, nosave););
		DTT1:Label[1] = STRrn;
		wait(0.1);
		If(
			vn == 1
		,
			DTM = DTT1 << Subset( All rows, Selected columns only( 0 ), Output Table("DTM"), Link to original data table( 0 ));
			try(Close(DTT1, nosave););
		,
			stop();
			DTM << Concatenate(DTT1, append to first table);
			wait(0.1);
			try(Close(DTT1, nosave););
		);
	);
);

By the time it gets to the stop command i've hit several problems:

1. none of the close data table commands have worked

2. the DTT1:Label[1]change has changed the label column in the DTM table for some reason

3. when running certain parts of the script after, eg highlighting DTT1 and DTM, the log seems to think these are the right data tables

4. trying to run the close command without try() gived the error: invalid argument in access or evaluation of 'Close' , Close/*###*/(DT1, nosave)

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Problems working with data tables created by Multiple File Import

This is tough to debug without a file structure available to read in a bunch of files. The method that I typically use, when I need to do something similar to this, is to use the Recursive option on the File in Directory() function, and then read in one file at a time, concatenate that file to the master, and then continue on to the next file.

Jim

View solution in original post

1 REPLY 1
txnelson
Super User

Re: Problems working with data tables created by Multiple File Import

This is tough to debug without a file structure available to read in a bunch of files. The method that I typically use, when I need to do something similar to this, is to use the Recursive option on the File in Directory() function, and then read in one file at a time, concatenate that file to the master, and then continue on to the next file.

Jim