https://github.com/queryverse/fstfiles.jl
FileIO.jl integration for fst files
https://github.com/queryverse/fstfiles.jl
Last synced: 5 months ago
JSON representation
FileIO.jl integration for fst files
- Host: GitHub
- URL: https://github.com/queryverse/fstfiles.jl
- Owner: queryverse
- License: other
- Created: 2017-11-06T18:06:17.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-06T18:13:29.000Z (over 8 years ago)
- Last Synced: 2025-05-19T23:43:47.710Z (about 1 year ago)
- Language: Julia
- Size: 6.84 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# FstFiles
[](http://www.repostatus.org/#active)
[](https://travis-ci.org/davidanthoff/FstFiles.jl)
[](https://ci.appveyor.com/project/davidanthoff/fstfiles-jl/branch/master)
[](http://pkg.julialang.org/?pkg=FstFiles)
[](http://codecov.io/github/davidanthoff/FstFiles.jl?branch=master)
## Overview
This package provides load support for [fst](http://www.fstpackage.org/)
files under the [FileIO.jl](https://github.com/JuliaIO/FileIO.jl) package.
## Installation
Use ``Pkg.add("FstFiles")`` in Julia to install FstFiles and its dependencies.
## Usage
### Load a fst file
To read a fst file into a ``DataFrame``, use the following julia code:
````julia
using FileIO, FstFiles, DataFrames
df = DataFrame(load("data.fst"))
````
The call to ``load`` returns a ``struct`` that is an [IterableTable.jl](https://github.com/davidanthoff/IterableTables.jl), so it can be passed to any function that can handle iterable tables, i.e. all the sinks in [IterableTable.jl](https://github.com/davidanthoff/IterableTables.jl). Here are some examples of materializing a fst file into data structures that are not a ``DataFrame``:
````julia
using FileIO, FstFiles, DataTables, IndexedTables, TimeSeries, Temporal, Gadfly
# Load into a DataTable
dt = DataTable(load("data.fst"))
# Load into an IndexedTable
it = IndexedTable(load("data.fst"))
# Load into a TimeArray
ta = TimeArray(load("data.fst"))
# Load into a TS
ts = TS(load("data.fst"))
# Plot directly with Gadfly
plot(load("data.fst"), x=:a, y=:b, Geom.line)
````
### Save a fst file
The following code saves any iterable table as a fst file:
````julia
using FileIO, FstFiles
save("output.fst", it)
````
This will work as long as ``it`` is any of the types supported as sources in [IterableTables.jl](https://github.com/davidanthoff/IterableTables.jl).
### Using the pipe syntax
Both ``load`` and ``save`` also support the pipe syntax. For example, to load a fst file into a ``DataFrame``, one can use the following code:
````julia
using FileIO, FstFiles, DataFrame
df = load("data.fst") |> DataFrame
````
To save an iterable table, one can use the following form:
````julia
using FileIO, FstFiles, DataFrame
df = # Aquire a DataFrame somehow
df |> save("output.fst")
````
The pipe syntax is especially useful when combining it with [Query.jl](https://github.com/davidanthoff/Query.jl) queries, for example one can easily load a fst file, pipe it into a query, then pipe it to the ``save`` function to store the results in a new file.