how to select multiple folders in scilab - scilab

I am looking for a function to select multiple directories in Scilab. I have found a similar function in Matlab Central uipickfiles.m. But is there a simpler and similar function in Scilab.
If it is not already available I am trying to write a function for the same.
Any suggestions/guidance is very appreciated.
regards
Devaraj

Since the built-in GUI does not allow you to select more directories, here is a workaround in 3 steps:
first select a "parent" directory, in which you want to select
multiple subdirectories
list the subdirectories
choose multiple subdirectories with an x_choices dialog
E.g.:
directory=uigetdir(); //select the parent directory, in which you want to choose multiple subdirectories!
allfiles=dir(directory); //all files in the directory
onlydirectories=allfiles.name(find(allfiles.isdir)); //select only the directories
if size(onlydirectories,"*")>1 then //there are 2 or more directory
L=list(list(onlydirectories(1),1,["-","+"])); //build the lists for x_choices:
for i=2:size(onlydirectories,"*")
L(i)=list(onlydirectories(i),1,["-","+"]);
end
rep=x_choices("Select directories with +",L); //multiple choices with toggle buttons
selecteddirectories=onlydirectories(find(rep==2));
disp(selecteddirectories,"selecteddirectories:");
selectedfullpath=directory+selecteddirectories+"\";
disp(selectedfullpath,"selectedfullpath:");
end
Not too pretty solution but it kind of works...

Related

how get count of parent Directories from zip (Compressed) file in qt c++?

Im new in qt. I use quazip for compress a folder and it compressed successfully.
But now if i want to know how many parents dir is available in unknown zip?
how can i get count of parent dir from zip file? before unzip.
please help me to get count of dir.
Is it possible by quazip? how?
QuaZip::getFileInfoList() should give you all the information needed. For the number of files just use the length of the returned list. Note that the file info is listed recursively. In case you need only the non-recursive content of a directory, go to that directory and iterate over all files with goToFirstFile() / goToNextFile().
I found the answer to my question:
Quazip zip("ZipFileName");
QuazipDir DirInZip(&zip);
int count = DirInZip.setFilter( QDir::Dir | QDir::NoDotAndDotDot|QDir::NoDot ).count();

Datastage Sequence job- how to process each file at a time if those files are in 7 different folders

DataStage - There are 7 folders in a path and in each folder there are 2 files . for eg : the 2 files are in the folllowing format- filename = test_s1_YYYYMMDD.txt, test_s1_YYYYMMDD.done. The path for these files are user/test/test_s1/
user/test/test_s2/
...
...
..
user/test/test_s7/------here s1,s2...s7 represents the different folders
In these folders the 2 above mentioned files are present , so how can i process each file in a sequence job?
First you need a job to process a file and the filename needs to be a parameter of that job.
For the Sequence level you need two levels - the inner one for the two files within each folder and a outer one for the different directories.
For the inner one you can choose to build a loop with to iterations or simply add the processing job twice to the sequence (which will reduce complexity in case it will always be two files).
The outer Sequence is a loop where you could parameterize the path in a way that the loop counter could be used to generate your 1-7 flexible path addon.
Check out more details on loops here
You can use the loop counter (stage_label.$Counter) to parameterize your job.
Depending on what you want to do with the files, it is an important decision how to process your files. Starting a job (or more) in a sequence for each file can lead to heavy overhead for just starting the jobs. Try loading all files at once in a parallel job using the sequenial file stage.
In the Sequential File Stage, set the appropriate Format. You can also set everything to none to just put each row in one column and process that in a later job. This will make the reading very flexible and forgiving. If your files are all the same structure, define your columns as needed.
To select the files, use File Patterns. In the Options of the Sequential File Stage, choose to have a File Name Column so you can process the filenames in a later job. You might also want to add a Row Number Column.
This method works pretty fast.

How to get QFileDialog to select and return multiple folders [duplicate]

This question already has an answer here:
PyQt QFileDialog - Multiple Directory Selection
(1 answer)
Closed 6 years ago.
I want to have the user be able to select multiple folders and then store the paths of those folders in a list.
How can i make that happen? My current QFileDialog looks like this:
str = QtGui.QFileDialog.getExistingDirectory(self, "Open Directory", /folder/subfolder, QtGui.QFileDialog.DontResolveSymlinks)
But of course, it only lets me select one folder. How can I change it to select multiple folders and return them in a list?
As far as I know you can't do that with the native FileDialog.
There, however, exists a workaround in which you don't use the native dialog:
file_dialog = QFileDialog()
file_dialog.setFileMode(QFileDialog.DirectoryOnly)
file_dialog.setOption(QFileDialog.DontUseNativeDialog, True)
file_view = file_dialog.findChild(QListView, 'listView')
# to make it possible to select multiple directories:
if file_view:
file_view.setSelectionMode(QAbstractItemView.MultiSelection)
f_tree_view = file_dialog.findChild(QTreeView)
if f_tree_view:
f_tree_view.setSelectionMode(QAbstractItemView.MultiSelection)
if file_dialog.exec():
paths = file_dialog.selectedFiles():
This workaround is a bit clunky however, but it's the best solution I know of other than rolling your own custom dialog.

Recursively search subdirectories to find the first instance of file

I have a complex dataset that is spread over 80 directories for each city (C). Each of these cities have multiple and unidentical subdirectories of varying depth. To clarify this means that for an example: city 1 can have 5 subdirectories a-e, where each subdirectory again can have multiple subdirectories. Now I need to find the first instance of a .txt file in each terminal subdirectory and apply a function to the txt file (logical function that is already written). There are no .txt files in the pre-terminal subdirectories.
lapply(list.dirs,function(x) {
if length(list.files(path=x,pattern=".txt"))==0 {
**apply function to .txt file}**
else {**lapply list.dirs etc---**}
However, I´m left with a neverending loop this way. How can this be done efficiently?
you may need something like this :
Treat_txt<-function(direct){
if(length(list.files(direct,pattern=".txt"))){
do what you need to do with the text file
} else {
dirs<-list.dirs(direct,full.names=T,recursive=F)
sapply(dirs,Treat_txt)
}
}
And then you can just call the function with the path of the "top" directory

Specify a Directory for Save in Mathematica

Considering :
ALLdwafDif[#] & /# symmetries
Save["ALLL.m", ALLL]
Is there a way to save the results in a particular directory ? It automatically save the results in my user directory now.
The current working directory is given by Directory[]. You can set it by SetDirectory[]. Alternatively, you can append the directory name to ALLL.m and it works.
eg
f = 5;
Save["~/Desktop/temp.m", f]
does what you'd expect (~ is a shortcut for home directory on most Unices, and mma respects it, so this gets saved on my desktop)
If you want to change the default working directory permanently you can add something like SetDirectory["new_dir"]; to one of the files $BaseDirectory/Kernel/init.m or $UserBaseDirectory/Kernel/init.m (which one depends on whether you want to change the default directory for all users or for the current user only). Next time you restart Mathematica, Directory[] will then automatically be set to new_dir.
Save[SystemDialogInput["FileSave", "All.m"], ALLL]
brings up a standard system save-file dialog box and saves your file after you've chosen a location (and a new file name if you have chosen one).
I find it useful to save data in the same location as the notebook:
f = 5;
Save[FileNameJoin[{NotebookDirectory[], "f.dat"}], f]
Or to save in your (default) Dropbox directory:
Save[FileNameJoin[{$HomeDirectory, "Dropbox", "f.dat"}], f]
I rarely use the directory stack that's controlled by SetDirectory[] and friends.

Resources