badele / cfwf

Read and write Customized Fixed Width Format flat file library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Choice of file format

badele opened this issue · comments

I'm trying to design a new flat file format, unlike CSV, with the aim of making it viewable without a specific reader.

The features are:

  • text -> cfwf
  • cfwf -> to an object of array type (currently deno and JavaScript are supported)
  • Ability to add multiple tables in the same file
  • Ability to add a title in ASCII art mode
  • Ability to add a subtitle for each table
  • Ability to add a comment for each table
  • Ability to add metadata for each table

I'm torn between three file formats:

  • Format A: Metadata is mostly in plain text
  • Format B: Metadata is in YAML format in each tables section
  • Format C: Metadata is in YAML format at end of the file

I must admit that I lean towards Format C because it seems more flexible and readeable (in case the file format evolves), but it has a slight drawback as it appears slightly less visible.

Feel free to share your feedback.

Format A

Metadata are calculated from markers, can be difficult to evolve over time

            
            ___   _____ ______    _____                     
           / _ \ |_   _|| ___ \  |_   _|                    
          / /_\ \  | |  | |_/ /    | |    ___   _   _  _ __ 
          |  _  |  | |  |  __/     | |   / _ \ | | | || '__|
          | | | |  | |  | |        | |  | (_) || |_| || |   
          \_| |_/  \_/  \_|        \_/   \___/  \__,_||_|   
                                                            
                             ┈┈┈                             
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 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

sources:
  - 'https://fr.wikipedia.org/wiki/Open_d%27Australie'
  - 'https://fr.wikipedia.org/wiki/Internationaux_de_France_de_tennis'
  - 'https://fr.wikipedia.org/wiki/US_Open_de_tennis'
  - 'https://fr.wikipedia.org/wiki/Tournoi_de_Wimbledon'
  - 'https://github.com/JeffSackmann/tennis_atp'
generated_with: 'Generated with https://github.com/badele/cfwf@0.0.1'
title: '     ATP Tour'
font: doom

Format B

Metadata is calculated from markers and also from a YAML flow for each table.

            
            ___   _____ ______    _____                     
           / _ \ |_   _|| ___ \  |_   _|                    
          / /_\ \  | |  | |_/ /    | |    ___   _   _  _ __ 
          |  _  |  | |  |  __/     | |   / _ \ | | | || '__|
          | | | |  | |  | |        | |  | (_) || |_| || |   
          \_| |_/  \_/  \_|        \_/   \___/  \__,_||_|   
                                                            
                             ┈┈┈                             
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.
                             ┈┈┈                             

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
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

align: []
source:
- 'https://github.com/JeffSackmann/tennis_atp'
- 'others sources'
tablename: players
others_metas: 'value'

                             ┈┈┈                             

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 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
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

source:
- 'https://github.com/JeffSackmann/tennis_atp'
- 'others sources'
tablename: 'australian'
others_metas: 'value'

                             ┈┈┈                             

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 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 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

source:
- 'https://github.com/JeffSackmann/tennis_atp'
- 'others sources'
tablename: 'australian'
others_metas: 'value'

                             ┈┈┈                             

sources:
  - 'https://fr.wikipedia.org/wiki/Open_d%27Australie'
  - 'https://fr.wikipedia.org/wiki/Internationaux_de_France_de_tennis'
  - 'https://fr.wikipedia.org/wiki/US_Open_de_tennis'
  - 'https://fr.wikipedia.org/wiki/Tournoi_de_Wimbledon'
  - 'https://github.com/JeffSackmann/tennis_atp'
generated_with: 'Generated with https://github.com/badele/cfwf@0.0.1'
title: '     ATP Tour'
font: doom

Format C

Metadata is calculated from markers and also from a YAML at the end of the file.

            
            ___   _____ ______    _____                     
           / _ \ |_   _|| ___ \  |_   _|                    
          / /_\ \  | |  | |_/ /    | |    ___   _   _  _ __ 
          |  _  |  | |  |  __/     | |   / _ \ | | | || '__|
          | | | |  | |  | |        | |  | (_) || |_| || |   
          \_| |_/  \_/  \_|        \_/   \___/  \__,_||_|   
                                                            
                             ┈┈┈                             
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 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

players:
  align: ["l", "r", "l", "c", "r", "r", "r"]
australian:
  align: ["r", "l", "c", "c"]
roland_garros:
  align: ["r", "l", "c", "c"]
_dataset_:
  sources:
    - 'https://fr.wikipedia.org/wiki/Open_d%27Australie'
    - 'https://fr.wikipedia.org/wiki/Internationaux_de_France_de_tennis'
    - 'https://fr.wikipedia.org/wiki/US_Open_de_tennis'
    - 'https://fr.wikipedia.org/wiki/Tournoi_de_Wimbledon'
    - 'https://github.com/JeffSackmann/tennis_atp'
  generated_with: 'Generated with https://github.com/badele/cfwf@0.0.1'
  title: '     ATP Tour'
  font: doom

There are extension to the usual Markdown format to play with tables, it might be interesting to look at these. kmarkdown does it fdrom memory.

We have released first version with Formac C solution