Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/queryverse/excelfiles.jl
FileIO.jl integration for Excel files
https://github.com/queryverse/excelfiles.jl
julia queryverse
Last synced: 7 days ago
JSON representation
FileIO.jl integration for Excel files
- Host: GitHub
- URL: https://github.com/queryverse/excelfiles.jl
- Owner: queryverse
- License: other
- Created: 2017-06-08T20:58:51.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-12-29T03:06:00.000Z (about 1 year ago)
- Last Synced: 2024-10-11T14:41:21.730Z (4 months ago)
- Topics: julia, queryverse
- Language: Julia
- Size: 186 KB
- Stars: 43
- Watchers: 3
- Forks: 11
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# ExcelFiles
[](http://www.repostatus.org/#active)
[](https://travis-ci.org/queryverse/ExcelFiles.jl)
[](https://ci.appveyor.com/project/queryverse/excelfiles-jl/branch/master)
[](http://codecov.io/github/queryverse/ExcelFiles.jl?branch=master)## Overview
This package provides load support for Excel files under the
[FileIO.jl](https://github.com/JuliaIO/FileIO.jl) package.## Installation
Use ``Pkg.add("ExcelFiles")`` in Julia to install ExcelFiles and its dependencies.
## Usage
### Load an Excel file
To read a Excel file into a ``DataFrame``, use the following julia code:
````julia
using ExcelFiles, DataFramesdf = DataFrame(load("data.xlsx", "Sheet1"))
````The call to ``load`` returns a ``struct`` that is an [IterableTable.jl](https://github.com/queryverse/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/queryverse/IterableTables.jl). Here are some examples of materializing an Excel file into data structures that are not a ``DataFrame``:
````julia
using ExcelFiles, DataTables, IndexedTables, TimeSeries, Temporal, Gadfly# Load into a DataTable
dt = DataTable(load("data.xlsx", "Sheet1"))# Load into an IndexedTable
it = IndexedTable(load("data.xlsx", "Sheet1"))# Load into a TimeArray
ta = TimeArray(load("data.xlsx", "Sheet1"))# Load into a TS
ts = TS(load("data.xlsx", "Sheet1"))# Plot directly with Gadfly
plot(load("data.xlsx", "Sheet1"), x=:a, y=:b, Geom.line)
````The ``load`` function also takes a number of parameters:
````julia
function load(f::FileIO.File{FileIO.format"Excel"}, range; keywords...)
````
#### Arguments:* ``range``: either the name of the sheet in the Excel file to read, or a full Excel range specification (i.e. "Sheetname!A1:B2").
* The ``keywords`` arguments are the same as in [ExcelReaders.jl](https://github.com/queryverse/ExcelReaders.jl) (which is used under the hood to read Excel files). When ``range`` is a sheet name, the keyword arguments for the ``readxlsheet`` function from ExcelReaders.jl apply, if ``range`` is a range specification, the keyword arguments for the ``readxl`` function apply.### Save an Excel file
The following code saves any iterable table as an excel file:
````julia
using ExcelFilessave("output.xlsx", it)
````
This will work as long as it is any of the types supported as sources in IterableTables.jl.### Using the pipe syntax
``load`` also support the pipe syntax. For example, to load an Excel file into a ``DataFrame``, one can use the following code:
````julia
using ExcelFiles, DataFramedf = load("data.xlsx", "Sheet1") |> DataFrame
````To save an iterable table, one can use the following form:
````julia
using ExcelFiles, DataFramedf = # Aquire a DataFrame somehow
df |> save("output.xlsx")
````The pipe syntax is especially useful when combining it with [Query.jl](https://github.com/queryverse/Query.jl) queries, for example one can easily load an Excel file, pipe it into a query, then pipe it to the ``save`` function to store the results in a new file.