Skip to content

Commit 41dc8c3

Browse files
author
Irene Alvarado
committed
Update readme to be more clear
1 parent 7acdaec commit 41dc8c3

1 file changed

Lines changed: 58 additions & 12 deletions

File tree

README.md

Lines changed: 58 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,40 @@
1-
# flat-postprocessing
1+
# Flat Data: Postprocessing Library and Examples
22

3-
A collection of postprocessing examples for [flat](https://github.com/githubocto/flat). You can import and use them directly, or treat them as a starting point for writing your own postprocessing scripts.
3+
A collection of postprocessing [helper functions](https://deno.land/x/flat/mod.ts) and examples for [Flat Data](https://github.com/githubocto/flat).
4+
5+
These examples and functions are written in [Deno](https://deno.land/), a new language created by the same founders of Node.js and meant to improve on many aspects of Node.
46

57
## Usage
68

7-
Your postprocessing scripts must read from the path passed as the first invocation argument, and print out the path to the processed data.
9+
When writing a [Flat Data]() Action, you can specify a path to a postprocessing Deno script that can manipulate the data downloaded by Flat even further.
10+
11+
```yaml
12+
- name: Fetch data
13+
uses: githubocto/flat@v2
14+
with:
15+
http_url: http://api.coindesk.com/v2/bpi/currentprice.json # The endpoint to fetch
16+
downloaded_filename: btc-price.json # The http_url gets saved and renamed in our repository as btc-price.json
17+
postprocess: postprocess.ts # A postprocessing javascript or typescript file written in Deno
18+
```
819
9-
The functions exported here are helpers to cut down on boilerplate.
20+
This is an example of a postprocessing script. Notice the use of `Deno.args[0]` to pass in the path of the `downloaded_filename`.
1021

1122
```ts
12-
import {readJSON, writeJSON} from 'https://deno.land/x/flat/mod.ts'
23+
// The Flat Data postprocessing libraries can be found at https://deno.land/x/flat/mod.ts
24+
// Replace 'x' with latest library version
25+
import { readJSON, writeJSON } from 'https://deno.land/x/flat@0.0.x/mod.ts'
1326
14-
const filename = Deno.args[0]
27+
const filename = Deno.args[0] // equivalent to writing `const filename = 'btc-price.json'`
1528
const data = await readJSON(filename)
16-
// pluck a specific key off
17-
// and write it out to a different file
18-
const newfile = `subset_of_${filename}`
29+
30+
// pluck a specific key off and write it out to a new file
31+
const newfile = `postprocessed_${filename}`
1932
await writeJSON(newfile, data.path.to.something)
20-
console.log(newfile)
2133
```
2234

2335
## Examples
2436

25-
Can be found in the examples folder:
37+
Can be found in the examples folder. Once you [install Deno](https://deno.land/) you can run these examples with:
2638

2739
* `deno run -A examples/csv/csv-example.ts`
2840
* `deno run -A examples/csv/arquero-example.ts`
@@ -32,6 +44,40 @@ Can be found in the examples folder:
3244
* `deno run -A examples/xlsx/xlsx-example.ts`
3345
* `deno run -A --unstable examples/zip/zip-example.ts`
3446

47+
Deno can run javascript or typescript files, so you can easily convert any of these examples to javascript and run them in the same way:
48+
49+
`deno run -A examples/csv/csv-example.js`
50+
51+
## Postprocessing Library
52+
53+
The Flat Data postprocessing library can be found at: [https://deno.land/x/flat/mod.ts](https://deno.land/x/flat/mod.ts)
54+
55+
You can import and use these helper functions directly, or treat them as a starting point for writing your own postprocessing scripts.
56+
57+
### CSV
58+
59+
TBD API
60+
61+
### JSON
62+
63+
TBD API
64+
65+
### XLSX
66+
67+
TBD API
68+
69+
### Image
70+
71+
TBD API
72+
73+
### Zip
74+
75+
TBD API
76+
77+
### Remove
78+
79+
TBD API
80+
3581
## Testing
3682

3783
Run all the tests:
@@ -45,5 +91,5 @@ Run separate tests
4591

4692
## License
4793

48-
MIT! See LICENSE
94+
[MIT](LICENSE)
4995

0 commit comments

Comments
 (0)