cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Craige_Hales
Super User
MFI from Selected CSVs in a ZIP

@Richardli  asked unzip + multi file import 

 

filename = Pick File( "Select zip File", "$DOCUMENTS", {"ZIP Files|zip", "All Files|*"}, 1, 0 );
// "/C:/Users/v1/Documents/saveappend.jmpaddin.zip"
If( filename != "" & File Exists( filename ), // check for canceled
	za = Open( filename, "zip" );
	listOfMembers = za << dir; // {"addin.def", "addin.jmpcust"};
	// build the gui list of checkboxes
	lb = Lineup Box( N Col( 3 ), spacing( 20 ) );
	For( i = 1, i <= N Items( listOfMembers ), i += 1,
		lb << append( Check Box( listOfMembers[i] ) )
	);

	New Window( "select members",
		lb,
		Button Box( "import selected",
			dir = Convert File Path( "$temp/deleteMeCSV/" ); // "/C:/Users/v1/AppData/Local/Temp/deleteMeCSV/"
			//delete directory(dir);// be CAREFUL !!! you might want to clean up before or after, but it does delete all the files!
			Create Directory( dir );
			Show( N Items( lb ) );
			names = "";
			For( i = 1, i <= N Items( lb ), i += 1,
				If( lb[i] << get/* is checked */,
					name = (lb[i] << get selected)[1]; // name of checked box is name of member
					names = names || name || ";"; // explicit list of names, in case dir has old names
					csvdata = za << read( name, Format( "blob" ) ); // load as blob, just in case
					name = Save Text File( dir || name, csvdata ); // save for mfi
				)
			);
			Multiple File Import( <<Set Folder( dir ), <<Set Name Filter( names ), <<Set Name Enable( 1 ), /* more parms here */ ) << Import Data;
		)
	);
);
Last Modified: Nov 23, 2021 8:46 AM