Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Reading files from folders with many files(>1000) is slow #19

@moerch

Description

@moerch

When loading files from a folder with many files (>1000) windows explorer is a bottleneck slowing the process down.

My suggestion is to add the following to read files from a given directory, with a common string.

Add the following line to ReelUserSettings:
UseCommonFiles = False

Add the following to Refinement_evaluator_ver1.0.py

def commonFiles(self,src):
    src = QtWidgets.QFileDialog.getExistingDirectory(self, 'Select path', src)
    string, _ = QtWidgets.QInputDialog.getText(self,"Common string","Common string file ends with")
    print(string)
    files = os.listdir(src)
    files.sort()
    print(files[0])

    files = [ os.path.join(src,x) for x in files if x.endswith(f"{string}")]
    print(len(files))
    _ , ext = os.path.splitext(string)
    print(files[0])
    print("*"+ext)
    return files,"*"+ext

Change

        filters = ext+';;'+';;'.join([x for x in filters.replace(ext,'').split(';;') if x])
        files, ext =  QtWidgets.QFileDialog.getOpenFileNames(self, 'Select files', path , filters)
    if len(files)<1:

to

        filters = ext+';;'+';;'.join([x for x in filters.replace(ext,'').split(';;') if x])
        if us.UseCommonFiles:
            files, ext = self.commonFiles(path) 
        else:
            files, ext =  QtWidgets.QFileDialog.getOpenFileNames(self, 'Select files', path , filters)
    if len(files)<1:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions