Parsers.jl

Fast parsing machinery for basic types in Julia
Popularity
98 Stars
Updated Last
10 Months Ago
Started In
June 2018

Parsers.jl

CI codecov deps version pkgeval

A collection of type parsers and utilities for Julia.

Installation: at the Julia REPL, import Pkg; Pkg.add("Parsers")

Maintenance: Parsers is maintained collectively by the JuliaData collaborators. Responsiveness to pull requests and issues can vary, depending on the availability of key collaborators.

Basic Usage

using Parsers

# basic int/float parsing
x = Parsers.parse(Int, "101")
y = Parsers.parse(Float64, "101.101")

# use comma as decimal
y2 = Parsers.parse(Float64, "101,101", Parsers.Options(decimal=','))

# Bool parsing
z = Parsers.parse(Bool, "true")

# Date/DateTime parsing
using Dates
a = Parsers.parse(Date, "2018-01-01")

# custom dateformat
b = Parsers.parse(Date, "01/20/2018", Parsers.Options(dateformat="mm/dd/yyyy"))

# will throw on invalid values
Parsers.parse(Int, "abc")

# tryparse will return `nothing` on invalid values
y = Parsers.tryparse(Int, "abc")

Additional usage

Read through the docs of the following types/functions for more information on using advanced Parsers machinery:

  • ?Parsers.Options
  • ?Parsers.xparse
  • ?Parsers.Result
  • ?Parsers.ReturnCode