Skip to content
This repository has been archived by the owner on May 5, 2019. It is now read-only.

Commit

Permalink
Update CSV examples to reflect that DataFrames is default CSV sink (#50)
Browse files Browse the repository at this point in the history
Current examples assume DataTable is the default sink.
  • Loading branch information
cjprybol authored and ararslan committed Apr 17, 2017
1 parent 9a287cb commit 46a4f3f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
15 changes: 10 additions & 5 deletions docs/src/man/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,19 @@ using CSV
using DataTables, CSV
```

Datasets can now be read using
A dataset can now be read from a CSV file at path `input` using
```julia
CSV.read(...)
CSV.read(input, DataTable)
```

and written using
Note the second positional argument of `DataTable`. This instructs the CSV package to output
a `DataTable` rather than the default `DataFrame`. Keyword arguments may be passed to
`CSV.read` after this second argument.

A DataTable can be written to a CSV file at path `output` using
```julia
CSV.write(...)
dt = DataTable(x = 1, y = 2)
CSV.write(output, dt)
```

For more information, use the REPL [help-mode](http://docs.julialang.org/en/stable/manual/interacting-with-julia/#help-mode) or checkout the online [CSV.jl documentation](https://juliadata.github.io/CSV.jl/stable/)!
Expand All @@ -179,7 +184,7 @@ For example, we can access Fisher's iris data set using the following functions:

```julia
using CSV
iris = CSV.read(joinpath(Pkg.dir("DataTables"), "test/data/iris.csv"))
iris = CSV.read(joinpath(Pkg.dir("DataTables"), "test/data/iris.csv"), DataTable)
head(iris)
```

Expand Down
2 changes: 1 addition & 1 deletion docs/src/man/reshaping_and_pivoting.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Reshape data from wide to long format using the `stack` function:
```julia
using DataTables
using CSV
iris = CSV.read(joinpath(Pkg.dir("DataTables"), "test/data/iris.csv"))
iris = CSV.read(joinpath(Pkg.dir("DataTables"), "test/data/iris.csv"), DataTable)
iris[:id] = 1:size(iris, 1) # this makes it easier to unstack
d = stack(iris, 1:4)
```
Expand Down
3 changes: 2 additions & 1 deletion docs/src/man/sorting.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Sorting is a fundamental component of data analysis. Basic sorting is trivial: j

```julia
using DataTables
iris = CSV.read(joinpath(Pkg.dir("DataTables"), "test/data/iris.csv"))
using CSV
iris = CSV.read(joinpath(Pkg.dir("DataTables"), "test/data/iris.csv"), DataTable)
sort!(iris)
```

Expand Down
3 changes: 2 additions & 1 deletion docs/src/man/split_apply_combine.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ We show several examples of the `by` function applied to the `iris` dataset belo

```julia
using DataTables
iris = CSV.read(joinpath(Pkg.dir("DataTables"), "test/data/iris.csv"))
using CSV
iris = CSV.read(joinpath(Pkg.dir("DataTables"), "test/data/iris.csv"), DataTable)

by(iris, :Species, size)
by(iris, :Species, dt -> mean(dropnull(dt[:PetalLength])))
Expand Down

0 comments on commit 46a4f3f

Please # to comment.