Skip to content

Commit

Permalink
prettier style, add a fun readme example
Browse files Browse the repository at this point in the history
  • Loading branch information
mhkeller committed Aug 22, 2019
1 parent 151d6ac commit 643748b
Show file tree
Hide file tree
Showing 3 changed files with 219 additions and 208 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ console.log(json_data)
]
*/

io.writeDataSync('path/to/save/output.json', json_data, {indent: 2})
io.writeDataSync('path/to/save/output.json', json_data, { indent: 2 })
```

Or, combine methods to read in a directory of csvs as json:
Expand All @@ -63,7 +63,7 @@ Or, combine methods to read in a directory of csvs as json:
var io = require('indian-ocean')

// Let's say this directory contains two csvs, each with two rows like the above example
var csvs = io.readdirFilterSync('csvs-folder', {include: 'csv', fullPath: true}).map(io.readDataSync)
var csvs = io.readdirFilterSync('csvs-folder', { include: 'csv', fullPath: true }).map(io.readDataSync)

console.log(csvs)

Expand Down Expand Up @@ -91,6 +91,17 @@ console.log(csvs)
]
]
*/

// Concatenate them into one file and write them out as one csv
io.writeDataSync('single-file.csv', csvs.flat())

/*
name,city
Gerald,Los Angeles
Marcy,Tuscaloosa
Liza,Minneapolis
Eileen,Mobile
*/
```

License
Expand Down
2 changes: 1 addition & 1 deletion docs/default_theme/top-matter._
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var json_data = io.readDataSync('<span class="hljs-string">path/to/data.csv'</sp
<span class="hljs-comment">]</span>
<span class="hljs-comment">*/</span>

io.writeDataSync(<span class="hljs-string">'path/to/save/output.json'</span>, json_data, {indent: 2})
io.writeDataSync(<span class="hljs-string">'path/to/save/output.json'</span>, json_data, { indent: 2 })
</pre>
</section>

Expand Down
Loading

0 comments on commit 643748b

Please sign in to comment.