MeridianMERIDIAN

File Extension

representation.file.extension

File name extension or suffix (txt, pdf, docx, jpg, etc.). May include or exclude leading dot.

Worked samples

DuckDB 1.5.5 · finetype 0.6.64

ValueAs VARCHARcategory
txttxtdocument
.pdfpdfdocument
docxdocxdocument
jpgjpgimage
xlsxxlsxother
Scope
broad_words

Shape

Pattern
^\.?[a-zA-Z0-9]{1,10}$
ValueLengthShape
txt3matches
.pdf4matches
docx4matches
jpg3matches
xlsx4matches

Told apart

1 of the 3 other file types accept every one of these samples on shape alone.

Going the other way, this type's own rule accepts 1 of 4 samples of File Size.

Background

Origin

The basic concept of extensions to indicate the type of file was first introduced in MIT's CTSS in 1961.[1] CTSS stored two separate names for each file, a file name and a class name, corresponding to today's name and extension.[1]

In DOS and 16-bit Windows, file names have a maximum of 8 characters, a period, and an extension of up to three letters.[1] The FAT file system stores a file name as an 8-character name and a three-character extension, and the period character is not stored.[1] The need to condense a file's type into three characters frequently led to abbreviated extensions, such as .TXT for plain text and .MUS for music.[1]

The classic Mac OS did without filename-based extensions entirely, using a distinct file type code to identify the file format instead.[1] macOS uses filename suffixes as a consequence of being derived from the UNIX-like NeXTSTEP operating system.[1]

Use

The exact rule for which part of a file name is its extension belongs to the file system, but usually the extension is the substring after the last dot, so txt is the extension of readme.txt.[1] Python's pathlib returns the suffix of my/library.tar.gz as .gz, with the leading dot included.[2] Python's pathlib returns an empty string as the suffix of a path with no extension, such as my/library.[2] More than one extension usually represents nested transformations, as in files.tar.gz, a tar archive compressed with gzip.[1] A column of extensions is easiest to compare once the leading dot is stripped and the case folded, so that .PDF, pdf and .pdf count as one value. (Meridian's view) Before you strip anything, check whether the column was cut at the last dot or the first: a source that wrote gz for an archive has lost the tar that tells you what is inside. (Meridian's view)

Some extensions have conflicting uses, such as .rpm, used for both RPM Package Manager packages and RealPlayer Media files.[1] File extensions alone are not a reliable indicator of a file's type, as the extension can be changed without changing the file's contents.[1] Treat an extension column as what the file claims to be, not what it is, and reach for a media type or the file's own bytes when the difference matters. (Meridian's view)

Sources

  1. [1]Filename extensionsecondary source
  2. [2]pathlib — Object-oriented filesystem pathsdocumentation

Detection notes

v1 migration: Was file.extension. Transform lowercases and removes leading dot for canonical form. Decompose infers file category (document, image, video, audio, archive).

Use it

CLI · DuckDB
$ finetype infer -i "txt" --mode column
→ representation.file.extension

SELECT ft_infer('txt');
-- → 'representation.file.extension'
Cast expression
LOWER(REGEXP_REPLACE({col}, '^\.*', ''))

Schema

https://meridian.online/schemas/representation.file.extension · Frictionless type string

finetype taxonomy representation.file.extension -o json-schema

Aliases

file_type

Type Registry