Skip to content

Commit

Permalink
feat: add command line and refacto the lib
Browse files Browse the repository at this point in the history
  • Loading branch information
badele committed Nov 26, 2023
1 parent f9e1559 commit 041b15a
Show file tree
Hide file tree
Showing 26 changed files with 2,048 additions and 816 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,18 @@ jobs:
run: "echo '${{ steps.release.outputs.version }}'"

- name: Generate Changelog
run: cog changelog --at ${{ steps.release.outputs.version }}
-t full_hash > GITHUB_CHANGELOG.md
run:
- cog changelog --at ${{ steps.release.outputs.version }}
-t full_hash > GITHUB_CHANGELOG.md
- deno fmt

- name: Generate tool and lib version
run: sed -i src/versions.ts
"s/\".*\"/\"${{ steps.release.outputs.version }}\"/"

- name: Update vesion in the Readme documentation
run: sed -i README.md
sed "s/\@[0-9]\.[0-9]\.[0-9]/@${{ steps.release.outputs.version }}/"

- name: Upload github release
uses: softprops/action-gh-release@v1
Expand Down
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.direnv
.coverage
samples/*.csv
samples/*.db
samples/tennis_atp
samples_regenerated.cfwf
samples/initdatas/*.csv
samples/initdatas/*.db
samples/initdatas/tennis_atp
samples/samples_regenerated.cfwf
112 changes: 88 additions & 24 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,107 @@
# Changelog
All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.

- - -
All notable changes to this project will be documented in this file. See
[conventional commits](https://www.conventionalcommits.org/) for commit
guidelines.

---

## [v0.1.0](https://github.com/badele/nix-projects/compare/1f01928591f654b573da7454d513374f0e99f433..v0.1.0) - 2023-11-16

#### Bug Fixes
- github CI badge - ([c90c1f1](https://github.com/badele/nix-projects/commit/c90c1f1384bf59385d9d9229b7dbc9d271c2d12e)) - [@badele](https://github.com/badele)
- remove some import modules - ([6357632](https://github.com/badele/nix-projects/commit/63576324ed4092053e5c74a9a6fe1cc30d5641ce)) - [@badele](https://github.com/badele)
- update github action (git checkout step) - ([709463c](https://github.com/badele/nix-projects/commit/709463c49ece3f0feee77437626ffc418ec722cf)) - [@badele](https://github.com/badele)

- github CI badge -
([c90c1f1](https://github.com/badele/nix-projects/commit/c90c1f1384bf59385d9d9229b7dbc9d271c2d12e)) -
[@badele](https://github.com/badele)
- remove some import modules -
([6357632](https://github.com/badele/nix-projects/commit/63576324ed4092053e5c74a9a6fe1cc30d5641ce)) -
[@badele](https://github.com/badele)
- update github action (git checkout step) -
([709463c](https://github.com/badele/nix-projects/commit/709463c49ece3f0feee77437626ffc418ec722cf)) -
[@badele](https://github.com/badele)

#### Continuous Integration
- get the samples datas - ([32607d1](https://github.com/badele/nix-projects/commit/32607d160cd403ac69b9edff97404661ca2eae32)) - [@badele](https://github.com/badele)

- get the samples datas -
([32607d1](https://github.com/badele/nix-projects/commit/32607d160cd403ac69b9edff97404661ca2eae32)) -
[@badele](https://github.com/badele)

#### Documentation
- update main readme.md - ([6d7e5f2](https://github.com/badele/nix-projects/commit/6d7e5f2eae6cbaa8c75728e67f2a476a724c2a77)) - [@badele](https://github.com/badele)
- update Readme - ([5233a6b](https://github.com/badele/nix-projects/commit/5233a6bf253f9d6322c5ddf9bccc973ab8a6ce20)) - [@badele](https://github.com/badele)

- update main readme.md -
([6d7e5f2](https://github.com/badele/nix-projects/commit/6d7e5f2eae6cbaa8c75728e67f2a476a724c2a77)) -
[@badele](https://github.com/badele)
- update Readme -
([5233a6b](https://github.com/badele/nix-projects/commit/5233a6bf253f9d6322c5ddf9bccc973ab8a6ce20)) -
[@badele](https://github.com/badele)

#### Features
- create a cfwf class - ([300f1c0](https://github.com/badele/nix-projects/commit/300f1c0118fec07a1a8ebc9c65f898f76677daff)) - [@badele](https://github.com/badele)
- add cfwf writer - ([4ad8a88](https://github.com/badele/nix-projects/commit/4ad8a88dfcf41aa15a6f01b73b8984f8f8ee72ca)) - [@badele](https://github.com/badele)

- create a cfwf class -
([300f1c0](https://github.com/badele/nix-projects/commit/300f1c0118fec07a1a8ebc9c65f898f76677daff)) -
[@badele](https://github.com/badele)
- add cfwf writer -
([4ad8a88](https://github.com/badele/nix-projects/commit/4ad8a88dfcf41aa15a6f01b73b8984f8f8ee72ca)) -
[@badele](https://github.com/badele)

#### Miscellaneous Chores
- **(version)** v0.1.0 - ([ee214bc](https://github.com/badele/nix-projects/commit/ee214bc85eccb62670ca3884d8a56f30b09b5fd6)) - github-actions

- **(version)** v0.1.0 -
([ee214bc](https://github.com/badele/nix-projects/commit/ee214bc85eccb62670ca3884d8a56f30b09b5fd6)) -
github-actions

#### Tests
- fix test linter - ([dadef2b](https://github.com/badele/nix-projects/commit/dadef2b4b15b0c73944d1dc348fff28d62a8c521)) - [@badele](https://github.com/badele)

- - -
- fix test linter -
([dadef2b](https://github.com/badele/nix-projects/commit/dadef2b4b15b0c73944d1dc348fff28d62a8c521)) -
[@badele](https://github.com/badele)

---

## [v0.1.0](https://github.com/badele/nix-projects/compare/1f01928591f654b573da7454d513374f0e99f433..v0.1.0) - 2023-11-16

#### Bug Fixes
- github CI badge - ([c90c1f1](https://github.com/badele/nix-projects/commit/c90c1f1384bf59385d9d9229b7dbc9d271c2d12e)) - [@badele](https://github.com/badele)
- remove some import modules - ([6357632](https://github.com/badele/nix-projects/commit/63576324ed4092053e5c74a9a6fe1cc30d5641ce)) - [@badele](https://github.com/badele)
- update github action (git checkout step) - ([709463c](https://github.com/badele/nix-projects/commit/709463c49ece3f0feee77437626ffc418ec722cf)) - [@badele](https://github.com/badele)

- github CI badge -
([c90c1f1](https://github.com/badele/nix-projects/commit/c90c1f1384bf59385d9d9229b7dbc9d271c2d12e)) -
[@badele](https://github.com/badele)
- remove some import modules -
([6357632](https://github.com/badele/nix-projects/commit/63576324ed4092053e5c74a9a6fe1cc30d5641ce)) -
[@badele](https://github.com/badele)
- update github action (git checkout step) -
([709463c](https://github.com/badele/nix-projects/commit/709463c49ece3f0feee77437626ffc418ec722cf)) -
[@badele](https://github.com/badele)

#### Continuous Integration
- get the samples datas - ([32607d1](https://github.com/badele/nix-projects/commit/32607d160cd403ac69b9edff97404661ca2eae32)) - [@badele](https://github.com/badele)

- get the samples datas -
([32607d1](https://github.com/badele/nix-projects/commit/32607d160cd403ac69b9edff97404661ca2eae32)) -
[@badele](https://github.com/badele)

#### Documentation
- update main readme.md - ([6d7e5f2](https://github.com/badele/nix-projects/commit/6d7e5f2eae6cbaa8c75728e67f2a476a724c2a77)) - [@badele](https://github.com/badele)
- update Readme - ([5233a6b](https://github.com/badele/nix-projects/commit/5233a6bf253f9d6322c5ddf9bccc973ab8a6ce20)) - [@badele](https://github.com/badele)

- update main readme.md -
([6d7e5f2](https://github.com/badele/nix-projects/commit/6d7e5f2eae6cbaa8c75728e67f2a476a724c2a77)) -
[@badele](https://github.com/badele)
- update Readme -
([5233a6b](https://github.com/badele/nix-projects/commit/5233a6bf253f9d6322c5ddf9bccc973ab8a6ce20)) -
[@badele](https://github.com/badele)

#### Features
- create a cfwf class - ([300f1c0](https://github.com/badele/nix-projects/commit/300f1c0118fec07a1a8ebc9c65f898f76677daff)) - [@badele](https://github.com/badele)
- add cfwf writer - ([4ad8a88](https://github.com/badele/nix-projects/commit/4ad8a88dfcf41aa15a6f01b73b8984f8f8ee72ca)) - [@badele](https://github.com/badele)

- create a cfwf class -
([300f1c0](https://github.com/badele/nix-projects/commit/300f1c0118fec07a1a8ebc9c65f898f76677daff)) -
[@badele](https://github.com/badele)
- add cfwf writer -
([4ad8a88](https://github.com/badele/nix-projects/commit/4ad8a88dfcf41aa15a6f01b73b8984f8f8ee72ca)) -
[@badele](https://github.com/badele)

#### Tests
- fix test linter - ([dadef2b](https://github.com/badele/nix-projects/commit/dadef2b4b15b0c73944d1dc348fff28d62a8c521)) - [@badele](https://github.com/badele)

- - -
- fix test linter -
([dadef2b](https://github.com/badele/nix-projects/commit/dadef2b4b15b0c73944d1dc348fff28d62a8c521)) -
[@badele](https://github.com/badele)

---

Changelog generated by [cocogitto](https://github.com/cocogitto/cocogitto).
Changelog generated by [cocogitto](https://github.com/cocogitto/cocogitto).
145 changes: 85 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
[![Build status](https://github.com/badele/cfwf/workflows/CI/badge.svg)](https://github.com/badele/cfwf/actions/workflows/CI.yml)
[![Code coverage](https://codecov.io/gh/badele/cfwf/branch/main/graph/badge.svg)](https://codecov.io/gh/badele/cfwf)

**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.
**cfwf** is a tool and library designed to facilitate the conversion of tables
into a human-readable format compatible with a simple text file reader.

## Project Motivation

Expand All @@ -25,63 +24,83 @@ tabular data.
- **Commentary and Metadata Inclusion:** Posibility to add comments and metadata
to the entire CFWF file, also for each table

## Example

### Code

```typescript
import { CFWF } from "./mod.ts";
import { parseCSV } from "./src/utils.ts";

const metas: any = {
title: " ATP Tour",
comment: "Here is a list of the best tennis players in the ATP rankings\n\
from 2012 to 2022, as well as the list of winners of the\n\
4 major Grand Slam tournaments.",
sources: [
"https://github.com/JeffSackmann/tennis_atp",
],
};

const samples = new CFWF(metas);

const players_txt = Deno.readTextFileSync("samples/players.csv");
const players = parseCSV(players_txt);

const australian_txt = Deno.readTextFileSync("samples/australian_open.csv");
const australian = parseCSV(australian_txt);

samples.addArray(
"players",
"The best players (number of winning matches) beetween 2012-2022 ",
"",
players.columns,
players.values,
{
aligns: ["left", "right", "left", "center", "right", "right", "right"],
sources: "https://github.com/JeffSackmann/tennis_atp",
},
);

samples.addArray(
"australian_open",
"Australian Open winners beetween 2012-2022",
"The Australian Open is a tennis tournament held annually at Melbourne Park\n\
in Melbourne, Victoria, Australia. The tournament is the first of the \n\
four Grand Slam tennis events held each year.",
["year", "tourney name", "birth nat", "winner"],
australian.values,
{
aligns: ["right", "left", "center", "center"],
sources: [
"https://fr.wikipedia.org/wiki/Open_d%27Australie",
"https://github.com/JeffSackmann/tennis_atp",
],
},
);
## Installation

```shell
curl -fsSL https://deno.land/x/install/install.sh | sh
deno install -A -fn cfwf https://deno.land/x/cfwf@0.0.1/mod.ts
cfwf convert -i https://media.githubusercontent.com/media/datablist/sample-csv-files/main/files/people/people-100.csv -o /tmp/people.cfwf
less -S /tmp/people.cfwf
```

### Result
## Usage

### Simple file conversion

```text
Usage: cfwf convert --input <intput> --output <output>
Version: 0.0.1
Description:
Convert files
Options:
-h, --help - Show this help.
-i, --input <intput> - Input filenme (required)
-o, --output <output> - Output filenme (required)
-t, --tablename <tablename> - Define table name
-s, --subtitle <subtitle> - Define table subtitle
-l, --columns <column> - Columns name (Default: [])
-a, --aligns <column> - Aligns for each columns
-S, --separate - Separate content & metadatas
```

```shell
cfwf convert -i https://media.githubusercontent.com/media/datablist/sample-csv-files/main/files/people/people-100.csv -o /tmp/people.cfwf
less -S /tmp/people.cfwf
```

### Multiples files conversion

```shell
cfwf dataset init -c /tmp/config.json

cfwf dataset set \
-c /tmp/config.json \
-t " CSV Samples" \
-d "$(cat << EOD
This is an example of how to convert a CSV file into a CFWF file.
The data comes from the https://github.com/datablist/sample-csv-files project.
Thanks to the author for providing the example data.
EOD
)
" \
-m '{ "sources": [ "https://github.com/datablist/sample-csv-files" ]}'

cfwf table add \
-c /tmp/config.json \
-f https://media.githubusercontent.com/media/datablist/sample-csv-files/main/files/people/people-100.csv \
-t peoples \
-s "The peoples list" \
-l "Index,User Id,First Name,Last Name,Sex,Email,Phone,Date of birth,Job Title" \
-a "right,right,right,left,center,left,left,center,left" \
-m '{ "sources": [ "https://github.com/datablist/sample-csv-files/tree/main/files/people" ]}'

cfwf table add \
-c /tmp/config.json \
-f https://media.githubusercontent.com/media/datablist/sample-csv-files/main/files/customers/customers-100.csv \
-t customers \
-s "The customers list" \
-l "Index,Customer Id,First Name,Last Name,Company,City,Country,Phone 1,Phone 2,Email,Subscription Date,Website" \
-a "right,right,right,left,right,left,right,right,left,left,center,left" \
-m '{ "sources": [ "https://github.com/datablist/sample-csv-files/tree/main/files/customers" ]}'

cfwf export -c /tmp/config.json -o | less -S
```

#### Result

```text
___ _____ ______ _____
Expand Down Expand Up @@ -139,7 +158,13 @@ year tourney name birth nat winner
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

## Samples

You can see more examples in the `samples/samplesscripts/` folder

## Sample dataset

The samples dataset provided by the
[JeffSackmann ATP tennis project](https://github.com/JeffSackmann/tennis_atp)
The samples dataset provided by :

- [JeffSackmann ATP tennis project](https://github.com/JeffSackmann/tennis_atp)
- [datablist sample csv files](https://github.com/datablist/sample-csv-files)
6 changes: 3 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ BROWSER := "chromium"

# Execute test tasks
@test: import-atp 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 @@ -37,10 +36,11 @@ coverage-browse browser="chromium": coverage
{{ browser }} ./.coverage/html_cov/index.html

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

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

# Run command interactively, view the result in realtime
@view:
Expand Down
Loading

0 comments on commit 041b15a

Please sign in to comment.