Skip to content

Commit

Permalink
feat: create a cfwf class
Browse files Browse the repository at this point in the history
  • Loading branch information
badele committed Nov 14, 2023
1 parent dadef2b commit bc5d433
Show file tree
Hide file tree
Showing 22 changed files with 1,533 additions and 387 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
.direnv
.coverage
samples/*.csv
samples/*.db
samples_regenerated.cfwf
109 changes: 82 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,84 @@
# cfwf

## TODO cfwf project initialisation

Enable **Read and write permissions** on the
[Github action workflow permission](https://github.com/badele/cfwf/settings/actions)
(for pushing the release and changelog)

## Included with this project

- nix/flake - reproducible, declarative and reliable developpement systems
- pre-commit
- cocogitto - conventional commits and auto versioning

## Git workflow

- `nix develop` or automatically loaded with `direnv` tool
- Conventional commits - `cog feat "message" scope`
- pre-commit hook
- markdownlint - markdown linter
- nixpkgs-fmt - nix linter
- github
- CI
- conventional commits
- lint
- test
- coverage
- Manually releasing a new version
[release action](https://github.com/badele/cfwf/actions/workflows/Release.yml)
## Introduction
**cfwf** is a library designed to facilitate the conversion of tables
or dictionaries into a human-readable format compatible with a
simple text file reader.

### Project Motivation
This project was initiated due to a dissatisfaction with the CSV file format,
which is often considered unreadable without the use of dedicated tools.
From my past experiences handling telematic files such as Minitel or BBS,
sought to develop a solution that would provide better readability
and usability for tabular data.

## Features
- **Conversion of Single or Multiple Tables:**
The cfwf library enables the conversion of one or more tables into
a single CFWF dataset file.

- **Commentary and Metadata Inclusion:**
Posibility to add comments and metadata to the entire CFWF file, also for each table

## Example

```text
___ _____ ______ _____
/ _ \ |_ _|| ___ \ |_ _|
/ /_\ \ | | | |_/ / | | ___ _ _ _ __
| _ | | | | __/ | | / _ \ | | | || '__|
| | | | | | | | | | | (_) || |_| || |
\_| |_/ \_/ \_| \_/ \___/ \__,_||_|
┈┈┈
Here is a list of the best tennis players in the ATP rankings
from 2012 to 2022, as well as the list of winners of the
4 major Grand Slam tournaments.
┈┈┈
players
The best players (number of winning matches) beetween 2012-2022
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
winner_ioc name_first name_last hand height birth nbwins
────────── ────────── ───────── ──── ────── ───── ──────
SRB Novak Djokovic R 188 1987 64
ESP Rafael Nadal L 185 1986 46
SUI Roger Federer R 185 1981 33
GBR Andy Murray R 190 1987 25
GER Alexander Zverev R 198 1997 19
AUT Dominic Thiem R 185 1993 17
RUS Daniil Medvedev R 198 1996 16
ESP David Ferrer R 175 1982 16
CRO Marin Cilic R 198 1988 14
RUS Andrey Rublev R 188 1997 13
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
The Australian Open is a tennis tournament held annually at Melbourne Park
in Melbourne, Victoria, Australia. The tournament is the first of the
four Grand Slam tennis events held each year.
australian_open
Australian Open winners beetween 2012-2022
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
year tourney name birth nat winner
──── ─────────────── ───────── ──────────────
2022 Australian Open ESP Rafael Nadal
2021 Australian Open SRB Novak Djokovic
2020 Australian Open SRB Novak Djokovic
2019 Australian Open SRB Novak Djokovic
2018 Australian Open SUI Roger Federer
2017 Australian Open SUI Roger Federer
2016 Australian Open SRB Novak Djokovic
2015 Australian Open SRB Novak Djokovic
2014 Australian Open SUI Stan Wawrinka
2013 Australian Open SRB Novak Djokovic
2012 Australian Open SRB Novak Djokovic
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

## Sample dataset

The samples dataset provided by the [JeffSackmann ATP tennis project](https://github.com/JeffSackmann/tennis_atp)
3 changes: 2 additions & 1 deletion deps.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Add your dependencies in here
import * as modfmt from "https://deno.land/std@0.204.0/fmt/printf.ts";
import * as modyaml from "https://deno.land/std@0.204.0/yaml/mod.ts";
import filget, { text } from "https://deno.land/x/deno_figlet@1.0.0/mod.ts";

export { filget, modfmt, text };
export { filget, modfmt, modyaml, text };
2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

deno
lcov

sqlite
];
shellHook = ''
export PROJ="cfwf"
Expand Down
8 changes: 7 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ BROWSER := "chromium"
cog check

# Execute test tasks
@test:
@test: generate-samples
deno run -A samples/scripts/generate_samples.ts
rm -rf ./.coverage
deno test --doc --unstable --allow-all --parallel --coverage=./.coverage --trace-ops

Expand All @@ -32,6 +33,11 @@ coverage-browse browser="chromium": coverage
genhtml -o ./.coverage/html_cov ./.coverage/cov.lcov
{{ browser }} ./.coverage/html_cov/index.html

@import-atp:
./samples/scripts/import-atp.sh

@generate-samples:
deno run -A samples/scripts/generate_samples.ts

# Run command interactively, view the result in realtime
@view:
Expand Down
6 changes: 5 additions & 1 deletion mod.ts
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
export { Align, arrayToCFWF } from "./src/cfwf_writer.ts";
export * from "./src/cfwf.ts";
export * from "./src/table.ts";
export * from "./src/cfwf_reader.ts";
export * from "./src/cfwf_writer.ts";
export * from "./src/types.ts";
20 changes: 0 additions & 20 deletions sample.cfwf

This file was deleted.

146 changes: 146 additions & 0 deletions samples.cfwf
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@

___ _____ ______ _____
/ _ \ |_ _|| ___ \ |_ _|
/ /_\ \ | | | |_/ / | | ___ _ _ _ __
| _ | | | | __/ | | / _ \ | | | || '__|
| | | | | | | | | | | (_) || |_| || |
\_| |_/ \_/ \_| \_/ \___/ \__,_||_|

┈┈┈
Here is a list of the best tennis players in the ATP rankings
from 2012 to 2022, as well as the list of winners of the
4 major Grand Slam tournaments.
┈┈┈

players
The best players (number of winning matches) beetween 2012-2022

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
winner_ioc name_first name_last hand height birth nbwins
────────── ────────── ───────── ──── ────── ───── ──────
SRB Novak Djokovic R 188 1987 64
ESP Rafael Nadal L 185 1986 46
SUI Roger Federer R 185 1981 33
GBR Andy Murray R 190 1987 25
GER Alexander Zverev R 198 1997 19
AUT Dominic Thiem R 185 1993 17
RUS Daniil Medvedev R 198 1996 16
ESP David Ferrer R 175 1982 16
CRO Marin Cilic R 198 1988 14
RUS Andrey Rublev R 188 1997 13
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The Australian Open is a tennis tournament held annually at Melbourne Park
in Melbourne, Victoria, Australia. The tournament is the first of the
four Grand Slam tennis events held each year.

australian_open
Australian Open winners beetween 2012-2022

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
year tourney name birth nat winner
──── ─────────────── ───────── ──────────────
2022 Australian Open ESP Rafael Nadal
2021 Australian Open SRB Novak Djokovic
2020 Australian Open SRB Novak Djokovic
2019 Australian Open SRB Novak Djokovic
2018 Australian Open SUI Roger Federer
2017 Australian Open SUI Roger Federer
2016 Australian Open SRB Novak Djokovic
2015 Australian Open SRB Novak Djokovic
2014 Australian Open SUI Stan Wawrinka
2013 Australian Open SRB Novak Djokovic
2012 Australian Open SRB Novak Djokovic
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The major tennis tournament held over two weeks at the Stade Roland Garros
in Paris, France, beginning in late May each year. The tournament and venue are
named after the French aviator Roland Garros. The French Open is the premier
clay court championship in the world and the only Grand Slam tournament
currently held on this surface.

roland_garros
Roland Garros winners beetween 2012-2022

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
year tourney name birth nat winner
──── ───────────── ───────── ──────────────
2022 Roland Garros ESP Rafael Nadal
2021 Roland Garros SRB Novak Djokovic
2020 Roland Garros ESP Rafael Nadal
2019 Roland Garros ESP Rafael Nadal
2018 Roland Garros ESP Rafael Nadal
2017 Roland Garros ESP Rafael Nadal
2016 Roland Garros SRB Novak Djokovic
2015 Roland Garros SUI Stan Wawrinka
2014 Roland Garros ESP Rafael Nadal
2013 Roland Garros ESP Rafael Nadal
2012 Roland Garros ESP Rafael Nadal
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The US Open Tennis Championships, commonly called the US Open, is a hardcourt tennis
tournament held annually in Queens, New York. Since 1987, the US Open has been
chronologically the fourth and final Grand Slam tournament of the year.

us_open
US Open winners beetween 2012-2022

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
year tourney name birth nat winner
──── ──────────── ───────── ───────────────
2022 Us Open ESP Carlos Alcaraz
2021 Us Open RUS Daniil Medvedev
2020 Us Open AUT Dominic Thiem
2019 US Open ESP Rafael Nadal
2018 US Open SRB Novak Djokovic
2017 US Open ESP Rafael Nadal
2016 US Open SUI Stan Wawrinka
2015 US Open SRB Novak Djokovic
2014 US Open CRO Marin Cilic
2013 US Open ESP Rafael Nadal
2012 US Open GBR Andy Murray
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The Championships, commonly known simply as Wimbledon, is the oldest tennis tournament
in the world and is regarded by many as the most prestigious.
It has been held at the All England Lawn Tennis and Croquet Club in Wimbledon, London, since 1877

wimbledon
wimbledon winners beetween 2012-2022

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
year tourney name birth nat winner
──── ──────────── ───────── ──────────────
2022 Wimbledon SRB Novak Djokovic
2021 Wimbledon SRB Novak Djokovic
2019 Wimbledon SRB Novak Djokovic
2018 Wimbledon SRB Novak Djokovic
2017 Wimbledon SUI Roger Federer
2016 Wimbledon GBR Andy Murray
2015 Wimbledon SRB Novak Djokovic
2014 Wimbledon SRB Novak Djokovic
2013 Wimbledon GBR Andy Murray
2012 Wimbledon SUI Roger Federer
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

_infos_:
font: doom
generated_with: 'Generated with https://github.com/badele/cfwf@0.0.1'
removetitlelines: 2
sources: ['https://github.com/JeffSackmann/tennis_atp']
title: ' ATP Tour'
australian_open:
aligns: [right, left, center, center]
sources: ['https://fr.wikipedia.org/wiki/Open_d%27Australie', 'https://github.com/JeffSackmann/tennis_atp']
players:
aligns: [left, right, left, center, right, right, right]
sources: 'https://github.com/JeffSackmann/tennis_atp'
roland_garros:
aligns: [right, left, center, center]
sources: ['https://fr.wikipedia.org/wiki/Internationaux_de_France_de_tennis', 'https://github.com/JeffSackmann/tennis_atp']
us_open:
aligns: [right, left, center, center]
sources: ['https://fr.wikipedia.org/wiki/US_Open_de_tennis', 'https://github.com/JeffSackmann/tennis_atp']
wimbledon:
aligns: [right, left, center, center]
sources: ['https://fr.wikipedia.org/wiki/Tournoi_de_Wimbledon', 'https://github.com/JeffSackmann/tennis_atp']
Loading

0 comments on commit bc5d433

Please sign in to comment.