Skip to content

Commit

Permalink
Add basic documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
abelsiqueira committed May 8, 2024
1 parent a2260f7 commit 60a36ce
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
# pkg> dev ..
#
[deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
TulipaIO = "7b3808b7-0819-42d4-885c-978ba173db11"

[compat]
Documenter = "1"
42 changes: 41 additions & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,44 @@ CurrentModule = TulipaIO

# TulipaIO

Documentation for [TulipaIO](https://github.com/TulipaEnergy/TulipaIO.jl).
[TulipaIO](https://github.com/TulipaEnergy/TulipaIO.jl) is part of the Tulipa ecosystem of packages.
The main package in this ecosystem is [TulipaEnergyModel.jl](https://tulipaenergy.github.io/TulipaEnergyModel.jl/stable/).
Check that package first for more information on the ecosystem.

## Usage

TulipaIO is used to provide input to TulipaEnergyModel and other packages in the ecosystem.
Here is some basic usage:

```@setup basic
using CSV: CSV
using DataFrames: DataFrame
df_asset = DataFrame(asset = [:ocgt, :demand], type = [:producer,:consumer])
CSV.write("assets-data-fake.csv", df_asset)
```

First, we read a fake CSV file with the relevant information.

```@example basic
using TulipaIO: TulipaIO
using DuckDB: DBInterface, DB
con = DBInterface.connect(DB)
filepath = joinpath(@__DIR__, "..", "..", "test", "data", "Norse", "assets-data.csv") #hide
table_name = TulipaIO.create_tbl(con, filepath) # filepath is the path to a CSV
```

Then we can run SQL commands using the DuckDB interface.
It returns a `DuckDB.QueryResult`, which we convert to Dict to visualize:

```@example basic
DBInterface.execute(con, "SELECT name, variable_cost FROM $table_name WHERE type = 'conversion'") |> Dict
```

This allows simple conversion to DataFrame as well:

```@example basic
using DataFrames: DataFrame
DataFrame(DBInterface.execute(con, "SELECT name, type, investable, variable_cost FROM $table_name WHERE name LIKE 'Asgard_%'"))
```

0 comments on commit 60a36ce

Please sign in to comment.