Smart sorting algorithm for files and folders in research projects and repositories
Project description
Scisort - Sort files in research projects
Scisort is a Python package for sorting files in research projects and scientific (data) repositories. Files and folders are sorted in such a way that inspecting folders in research projects is more intuitive. See the philosophy of scisort to understand the sorting algorithm.
Since scisort is a low-level API, most researchers, developers, and data
scientists may be more interested in scitree
.
Scitree is a smart recursive directory listing program that makes use of scisort.
Philosophy of scisort
Philosophy of scisort and scitree:
- Read the README first, therefore I'm on top
- Before I install or use the content, I open the LICENSE.
- Files first, folders second
- Numbered files are naturally sorted
- I love intuitive and reproducible project structures
- Follow the order of execution where possible
- I ignore, what git ignores*
* Only for scitree
.
For more information about the structure, see scisort/scisort/keygen.py.
Installation
Scisort requires Python 3.6 or later.
pip install scisort
Getting started
Traditional sorting
Consider the following project folder structure. It's a mixture of files and folders. The folder is sorted on the file or folder name. Some reasons why this sort is not intuitive:
files = ['LICENSE.txt',
'README.md',
'data',
'data/Bos_2018.csv',
'jobs.sh',
'output',
'output/simulation',
'output/simulation/Bos_2018',
'output/simulation/Bos_2018/descriptives',
'output/simulation/Bos_2018/descriptives/data_stats_Bos_2018.json',
'output/simulation/Bos_2018/descriptives/wordcloud_Bos_2018.png',
'output/simulation/Bos_2018/descriptives/wordcloud_irrelevant_Bos_2018.png',
'output/simulation/Bos_2018/descriptives/wordcloud_relevant_Bos_2018.png',
'output/simulation/Bos_2018/metrics_sim_Bos_2018_0.json',
'output/simulation/Bos_2018/metrics_sim_Bos_2018_1640.json',
'output/simulation/Bos_2018/metrics_sim_Bos_2018_3154.json',
'output/simulation/Bos_2018/metrics_sim_Bos_2018_3518.json',
'output/simulation/Bos_2018/metrics_sim_Bos_2018_3519.json',
'output/simulation/Bos_2018/metrics_sim_Bos_2018_3721.json',
'output/simulation/Bos_2018/metrics_sim_Bos_2018_4612.json',
'output/simulation/Bos_2018/metrics_sim_Bos_2018_4699.json',
'output/simulation/Bos_2018/metrics_sim_Bos_2018_559.json',
'output/simulation/Bos_2018/metrics_sim_Bos_2018_5673.json',
'output/simulation/Bos_2018/metrics_sim_Bos_2018_6.json',
'output/simulation/Bos_2018/plot_recall_sim_Bos_2018.png',
'output/simulation/Bos_2018/state_files',
'output/simulation/Bos_2018/state_files/sim_Bos_2018_0.asreview',
'output/simulation/Bos_2018/state_files/sim_Bos_2018_1640.asreview',
'output/simulation/Bos_2018/state_files/sim_Bos_2018_3154.asreview',
'output/simulation/Bos_2018/state_files/sim_Bos_2018_3518.asreview',
'output/simulation/Bos_2018/state_files/sim_Bos_2018_3519.asreview',
'output/simulation/Bos_2018/state_files/sim_Bos_2018_3721.asreview',
'output/simulation/Bos_2018/state_files/sim_Bos_2018_4612.asreview',
'output/simulation/Bos_2018/state_files/sim_Bos_2018_4699.asreview',
'output/simulation/Bos_2018/state_files/sim_Bos_2018_559.asreview',
'output/simulation/Bos_2018/state_files/sim_Bos_2018_5673.asreview',
'output/simulation/Bos_2018/state_files/sim_Bos_2018_6.asreview',
'output/tables',
'output/tables/data_descriptives.csv',
'output/tables/data_descriptives.xlsx',
'output/tables/data_metrics.csv',
'output/tables/data_metrics.xlsx',
'scripts',
'scripts/get_plot.py',
'scripts/merge_descriptives.py',
'scripts/merge_metrics.py']
The files and folders are real research output created with ASReview-makita
(see examples).
Scisort sorting
Scisort integrates with Python's sorted
by supplying the sort key.
from scisort import scisort_keygen
sorted(files, key=scisort_keygen())
['README.md',
'LICENSE.txt',
'jobs.sh',
'data',
'data/Bos_2018.csv',
'scripts',
'scripts/get_plot.py',
'scripts/merge_descriptives.py',
'scripts/merge_metrics.py',
'output',
'output/simulation',
'output/simulation/Bos_2018',
'output/simulation/Bos_2018/metrics_sim_Bos_2018_0.json',
'output/simulation/Bos_2018/metrics_sim_Bos_2018_6.json',
'output/simulation/Bos_2018/metrics_sim_Bos_2018_559.json',
'output/simulation/Bos_2018/metrics_sim_Bos_2018_1640.json',
'output/simulation/Bos_2018/metrics_sim_Bos_2018_3154.json',
'output/simulation/Bos_2018/metrics_sim_Bos_2018_3518.json',
'output/simulation/Bos_2018/metrics_sim_Bos_2018_3519.json',
'output/simulation/Bos_2018/metrics_sim_Bos_2018_3721.json',
'output/simulation/Bos_2018/metrics_sim_Bos_2018_4612.json',
'output/simulation/Bos_2018/metrics_sim_Bos_2018_4699.json',
'output/simulation/Bos_2018/metrics_sim_Bos_2018_5673.json',
'output/simulation/Bos_2018/plot_recall_sim_Bos_2018.png',
'output/simulation/Bos_2018/descriptives',
'output/simulation/Bos_2018/descriptives/wordcloud_Bos_2018.png',
'output/simulation/Bos_2018/descriptives/wordcloud_irrelevant_Bos_2018.png',
'output/simulation/Bos_2018/descriptives/wordcloud_relevant_Bos_2018.png',
'output/simulation/Bos_2018/descriptives/data_stats_Bos_2018.json',
'output/simulation/Bos_2018/state_files',
'output/simulation/Bos_2018/state_files/sim_Bos_2018_0.asreview',
'output/simulation/Bos_2018/state_files/sim_Bos_2018_6.asreview',
'output/simulation/Bos_2018/state_files/sim_Bos_2018_559.asreview',
'output/simulation/Bos_2018/state_files/sim_Bos_2018_1640.asreview',
'output/simulation/Bos_2018/state_files/sim_Bos_2018_3154.asreview',
'output/simulation/Bos_2018/state_files/sim_Bos_2018_3518.asreview',
'output/simulation/Bos_2018/state_files/sim_Bos_2018_3519.asreview',
'output/simulation/Bos_2018/state_files/sim_Bos_2018_3721.asreview',
'output/simulation/Bos_2018/state_files/sim_Bos_2018_4612.asreview',
'output/simulation/Bos_2018/state_files/sim_Bos_2018_4699.asreview',
'output/simulation/Bos_2018/state_files/sim_Bos_2018_5673.asreview',
'output/tables',
'output/tables/data_descriptives.csv',
'output/tables/data_descriptives.xlsx',
'output/tables/data_metrics.csv',
'output/tables/data_metrics.xlsx']
Third party support
Scisort also integrates with other libraries implementing sorting based on a key.
Pandas
import pandas as pd
from scisort import scisort_keygen_pandas
pd.Series(files).sort_values(key=scisort_keygen_pandas())
Natsort
import natsort as ns
ns.natsorted(files, key=scisort_keygen())
License
Contact
Feel free to reach out with questions, remarks, and suggestions. The issue tracker is a good starting point. You can also email me at jonathandebruinos@gmail.com.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file scisort-0.5.3.tar.gz
.
File metadata
- Download URL: scisort-0.5.3.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51a584103f45d7bb60d18b7c2f170566aa308c7e07c9e7cdd367e7ccafe556d6 |
|
MD5 | a6284a61c2b6fc1f14ab90aea5cdfea7 |
|
BLAKE2b-256 | 83da423b3a1bd597c3b8777ac314eb3eaaaf49787f2b3521832c634f79a9a70f |
File details
Details for the file scisort-0.5.3-py3-none-any.whl
.
File metadata
- Download URL: scisort-0.5.3-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ae1358f43bbffadac4a3ae7eb5f16c7715425cdf43724ae459ebe17d12a3914 |
|
MD5 | c5fe315e645ee8f2be356d8a6f8cf285 |
|
BLAKE2b-256 | b8fad2330777245f0a9aca7af0d081c1ebe6bdf8f6fa56aa84d32ce95b1e297a |