echemdb / unitpackage

A Python library to interact with a collection of frictionless datapackages
https://echemdb.github.io/unitpackage/
GNU General Public License v3.0
4 stars 3 forks source link

Save selected entries in specific subfolders. #41

Open DunklesArchipel opened 8 months ago

DunklesArchipel commented 8 months ago
          We might want to add possibilities to save selected entries in specific subfolders.

We could define an outdir_pattern which creates an outdir from descriptors within an entry.

def pattern(outdir, entry):
    return os.path.join(outdir, entry.user) # stores entries based on the user who created the package

def save_entries(self, outdir=None, outdir_pattern=pattern):
    for entry in self:
        if outdir_pattern:
            outdir = outdir_pattern(outdir, entry)
            entry.save(outdir=outdir)

We could implement a similar approach for the filename.

_Originally posted by @DunklesArchipel in https://github.com/echemdb/unitpackage/pull/39#discussion_r1518977930_