01:00
STAT 159: Collaborative and Reproducible Data Science
If you don’t have a GitHub account, please sign up for one.
Many of you are used to work on projects with a very simple file structure, e.g.
What if there is some data file …
Let’s now talk about Naming Files
meeting.docagenda.docimportant.docmyreport.qmd
John's filename uses spaces and punctuation.txt
figure I.png
fig 2.png
plot 3.png
amazingmachinelearningscript.ipynb
Don’t! 👎
myreport.qmd2026-08-28_sales-report.qmdJohn's filename uses spaces and punctuation.txtjohn-filename-looks-better.txtfigure I.pngfig 2.pngfig01_histogram-height.png, fig02_histogram-weight.pngplot 3.pngfig03_scatterplot-height-weight.pngamazingmachinelearningscript.ipynbregularization-models-script.ipynb
2026-05-06_collisions_Berkeley.csv
2026-05-06_collisions_Oakland.csv
2026-05-06_collisions_San-Francisco.csv
2026-05-06_collisions_San-Jose.csv
2026-05-06_stop-data_Berkeley.csv
2026-05-06_stop-data_Oakland.csv
2026-05-06_stop-data_San-Francisco.csv
2026-05-06_stop-data_San-Jose.csv
Regular expression and globbing friendly
Avoid:
Easy to compute on
- and _2026-05-06_collisions_Berkeley.csv
2026-05-06_collisions_Oakland.csv
2026-05-06_collisions_San-Francisco.csv
2026-05-06_collisions_San-Jose.csv
2026-05-06_stop-data_Berkeley.csv
2026-05-06_stop-data_Oakland.csv
2026-05-06_stop-data_San-Francisco.csv
2026-05-06_stop-data_San-Jose.csv
Deliberate use of _ and - allows us to recover metadata from the filenames.
2026-05-06_collisions_Berkeley.csv
2026-05-06_collisions_Oakland.csv
2026-05-06_collisions_San-Francisco.csv
2026-05-06_collisions_San-Jose.csv
2026-05-06_stop-data_Berkeley.csv
2026-05-06_stop-data_Oakland.csv
2026-05-06_stop-data_San-Francisco.csv
2026-05-06_stop-data_San-Jose.csv
foo and Foo)Name contains info on content
Connects to concept of a slug from semantic URLs
01_download-data.qmd
02_clean-data.qmd
03_univariate-eda.qmd
04_run-simulation.qmd
helper01_data-parsers.R
helper02_summary-functions.R
Easy to figure out what the heck something is, based on its name
01:00
association-coefficients.R
clean-data.qmd
data-parsers.R
download-data.qmd
run-simulation.qmd
summary-functions.R
univariate-eda.qmd01:30
Put something numeric first
Use the ISO 8601 standard for dates: YYYY-MM-DD
Left pad other numbers with zeros
1, 2, …, 9 (good if less than 10)01, 02, …, 09, 10, 11 (ok if < 100)001, 002, …, 99, 100, 101 (ok if < 1000)Are you more likely to remember a filename of a timeframe?
YYYY-MM-DD
Make it:
Easy to implement NOW
Dividends multiply as your skills evolve and projects get more complex.
\ / * & % ? $ | ^ ~ < >- as the first characterMyFile vs myfile
.txt, .csv, .html, .md, .pdf, .jpgYYYYMM will sort differently than files starting with the MMDDYYYY format.Ideally, pick three pieces of metadata; use no more than five.
This metadata should be enough for you to visually scan the file names and easily understand what’s in each one.
Example: For my images, I want to know date, sample ID, and image number for that sample on that date.
If any of the metadata from step 1 is described by lots of text, decide what shortened information to keep.
If any of the metadata from step 1 has regular categories, standardize the categories and/or replace them with 2- or 3-letter codes; be sure to document these codes.
Example: Sample ID will use a code made up of: a 2-letter project abbreviation (project 1 = P1, project 2 = P2); a 3-letter species abbreviation (mouse = “MUS”, fruit fly = “DRS”); and 3-digit sample ID (assigned in my notebook).
Think about how you want to sort and search for your files to decide what metadata should appear at the beginning of the file name.
If date is important, use ISO 8601-formatted dates (YYYYMMDD or YYYY-MM-DD) at the beginning of the file names so dates sort chronologically.
Example 1: My sample ID is most important so I will list it first, followed by date, then image number
Many computer systems cannot handle spaces in file names.
To make file names both computer- and human-readable, use dashes (-), underscores (_), and/or capitalize the first letter of each word in the file names.
Example: I will use underscores to separate metadata and dashes between parts of my sample ID.
You can track versions of a file by appending version information to end of the file name.
Consider using a version number (e.g. v01) or the version date (use ISO 8601 format: YYYYMMDD or YYYY-MM-DD).
Example: As each image goes through my analysis workflow, I will append the version type to the end of the file name (e.g. _raw, _processed, and _composite)
Make sure the convention only uses alphanumeric characters, dashes, and underscores. Ideally, file names will be 32 characters or less.
Example: my file naming convention is
SA-MPL-EID_YYYYMMDD_###_status.tifExamples are P1-MUS023_20200229_051_raw.tif and P2-DRS-285_20191031_062_composite.tif
