Skip to main content

⚽ Common Data Format Schema Validator

JSON and JSONLines Schema Validition for the Soccer Common Data Format.

Anzer, G., Arnsmeyer, K., Bauer, P., Bekkers, J., Brefeld, U., Davis, J., Evans, N., Kempe, M., Robertson, S. J., Smith, J. W., & Van Haaren, J. (2025). Common Data Format (CDF)—a Standardized Format for Match-Data in Football (Soccer). [Unpublished manuscript / Preprint].


Changelog

See CHANGELOG.md


How To

1. Install package

pip install common-data-format-validator

2. Create your own schema

Create your data schema according to the Common Data Format specificiations for any of:

  • Offical Match Data
  • Meta Data
  • Event Data
  • Tracking Data
  • Landmark Tracking Data
  • Video Data

3. Test your schema

Once you have created your schema, you can check it's validity using the available SchemaValidators for each of the above mentioned data types.

import cdf

# # Example valid tracking data
validator = cdf.TrackingSchemaValidator()
validator.validate_schema(sample=f"cdf/files/v{cdf.VERSION}/sample/tracking.jsonl", limit=1)

# Example valid meta data
validator = cdf.MetaSchemaValidator()
validator.validate_schema(sample=f"cdf/files/v{cdf.VERSION}/sample/meta.json")

# Example valid event data
validator = cdf.EventSchemaValidator()
validator.validate_schema(sample=f"cdf/files/v{cdf.VERSION}/sample/event.jsonl", limit=1)

# Example valid match data
validator = cdf.MatchSchemaValidator()
validator.validate_schema(sample=f"cdf/files/v{cdf.VERSION}/sample/match.json")

# Example valid landmark data
validator = cdf.LandmarkSchemaValidator()
validator.validate_schema(sample=f"cdf/files/v{cdf.VERSION}/sample/landmark.jsonl", limit=1)

# Example valid video data
validator = cdf.VideoSchemaValidator()
validator.validate_schema(sample=f"cdf/files/v{cdf.VERSION}/sample/video.json")
Validation modes

validate_schema takes a mode that decides how findings are reported.

validator = cdf.MetaSchemaValidator()

# Report everything, raise nothing. Useful for a first look at a new file.
validator.validate_schema(sample="my_meta.json", mode="soft")

# Fail on anything the schema forbids, but tolerate extra keys.
validator.validate_schema(sample="my_meta.json", mode="strict")

# Also fail on keys the CDF does not define, e.g. a typo or an extension.
validator.validate_schema(sample="my_meta.json", mode="extreme")

Note

The validator checks:

  • All mandatory fields are provided
  • Snake case is adhered for each key and for values (except for player names, city names, venue names etc.)
  • Data types are correct (e.g. boolean, integer etc.)
  • Value entries for specific fields are correct (e.g. period type can only be one of 5 values)
  • Position groups and positions follow naming conventions
  • Color codes are hex (e.g. #FFC107)
  • Position labels fit within the formation specifications
  • Correct pitch dimensions (Simply checks if they are "x" between -65.0 and 65.0 and "y" between -42.5 and +42.5)
  • Correct JSONLines line separator ('\n')
  • Check multiple lines by setting limit. Only works for JSONL files. limit=None checks the whole file.

The validator (currently) does not check:

  • Correct UTF-8 encoding
  • British spelling (currently only for "color" / "colour" keys)
  • If player_ids (or other ids) in meta are in tracking, event etc. or vice versa
Missing values

Where a field has no value the CDF distinguishes two cases. A null value means the field applies to that record but there is nothing to record, so an event that ends with nobody in possession carries receiver_id: null. An absent key means the field does not apply to that kind of record at all, so a referee event leaves out player_id and team_id and carries official_id instead.


Contributing

Keep each commit to one change to the format. The schema edit, its sample and the regenerated output belong in the same commit, but two unrelated changes should be two commits, even where they touch the same schema. Essentially, a change is a request to edit / update / append the CDF. Each change needs to be reviewable on it's own.

The JSON Schemas in cdf/files/v{VERSION}/schema/ are the source of truth. The domain models and the documentation site are both generated from them:

Generated Command
cdf/domain/latest/*.py (TypedDict models) python src/generate_latest_domain.py
docs/ (the cdf.football pages) python src/generate_docs.py

You do not need to update the domain models yourself. Changes to the format belong in the schema, and anything edited directly in cdf/domain/latest/ or docs/ is replaced the next time the generators run. CI regenerates both on every pull request and fails if the result differs from what was committed, so the two stay in step.

A change to the format is:

  1. Edit the schema in cdf/files/v{VERSION}/schema/
  2. Update the matching sample in cdf/files/v{VERSION}/sample/ so it still validates
  3. Run python src/generate_latest_domain.py and python src/generate_docs.py
  4. Add a CHANGELOG.md entry under the table the change belongs to
  5. Commit the schema, the sample and the regenerated output together

Both generators format their own output.


Versions

This validator currently relies on CDF "alpha" version 2, but includes all logical changes not yet reflected in the text of this version, as discussed in the Changelog

The format and the package are versioned separately.

Read from Currently
CDF format cdf.VERSION 0.3.2
Python package cdf.__version__ 0.1.1

cdf.VERSION selects which CDF schemas you validate against, in cdf/files/v{VERSION}/, and is the version the Changelog is written against. cdf.__version__ is the package release published to PyPI.


Software by Joris Bekkers

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

common_data_format_validator-0.1.1.tar.gz (131.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

common_data_format_validator-0.1.1-py3-none-any.whl (170.4 kB view details)

Uploaded Python 3

File details

Details for the file common_data_format_validator-0.1.1.tar.gz.

File metadata

File hashes

Hashes for common_data_format_validator-0.1.1.tar.gz
Algorithm Hash digest
SHA256 07ded8c028a636296a0e66e8de0855d8b146d921e23d820239110e945f86e5a5
MD5 1ca91d2e695d089ba88ae177e1df25ae
BLAKE2b-256 660cd7e2815a67cee8feda8d20cfbba98bc119a8c402299e0bfd3326bb4e0004

See more details on using hashes here.

File details

Details for the file common_data_format_validator-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for common_data_format_validator-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6fa0d8a54f783b237077e23232b634f29bc787b90c6882bc7de446c6ed983ca2
MD5 180cb9497b1ab3826fd655f34eca171f
BLAKE2b-256 34b0db2ae42a817dba34a7e8d8f7818beeacde2fccd8c8ab0d35588c467aa526

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 files

0.0.14

2 files

0.0.13

2 files

0.0.12

2 files

0.0.11

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page