Search code examples
juliaijulia-notebook

Julia os type of package or library?


I am new to Julia, and beginning to port some machine learning projects over to Julia. One thing I am missing is the python os library which can walk a directory path quite easily. I am googling around and looks like it doesn't exist in Julia yet.. but wanted to throw up a question before I start writing my own implementation

for context here's the python function I'm porting

import os
import fnmatch

def list_all_files(directory, extensions=None):
    for root, dirnames, filenames in os.walk(directory):
        for filename in filenames:
            base, ext = os.path.splitext(filename)
            joined = os.path.join(root, filename)
            if extensions is None or ext.lower() in extensions:
                yield joined

Solution

  • Have a look at walkdir. You can also use readdir(), maybe in combination with filter().

    Example:

    for d in filter(isdir, readdir())
        println("I'm a directory: ", d)
    end