Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bkamins/nanocsv.jl
A minimal implementation of CSV reader/writer for Julia
https://github.com/bkamins/nanocsv.jl
csv julia
Last synced: 26 days ago
JSON representation
A minimal implementation of CSV reader/writer for Julia
- Host: GitHub
- URL: https://github.com/bkamins/nanocsv.jl
- Owner: bkamins
- License: mit
- Created: 2018-09-11T08:31:59.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-10-04T18:28:32.000Z (over 6 years ago)
- Last Synced: 2024-10-30T18:47:59.275Z (2 months ago)
- Topics: csv, julia
- Language: Julia
- Size: 33.2 KB
- Stars: 2
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Nanocsv.jl
=============A minimal implementation of CSV reader/writer for Julia.
It reads and writes `DataFrames` from/to file on disk.**Installation**: at the Julia REPL, `using Pkg; Pkg.add(PackageSpec(url="https://github.com/bkamins/Nanocsv.jl"))`
### Design
* always use `"` as quote character, `""` represents a quote in quoted field
* you can change field separator using `delim` keyword argument
* when data is written to disk then `string` function is used to get its representation
* by default tries to parse columns to `Int`, `Float64` using `parse` function and falls back to `String`; you can change list or sequence of tried parsers using `parsers` keyword argument
* handles missing values using `na` keyword argument; `na` is always *unquoted* when reading/writing (except if header line is present in a file as then it is read as is); if string equal to `na` is written it is always quoted; if value equal to `na` is quoted in file then it is treated as a valid value not `missing`### Functions provided
Writing CSV to disk:
```julia
write_csv(io::IO, df::DataFrame;
delim::Char=',', na::AbstractString="")
write_csv(filename::AbstractString, df::DataFrame;
delim::Char=',', na::AbstractString="")
```Reading CSV from disk:
```julia
read_csv(io::IO;
delim::Char=',', header::Bool=true, na::String="",
parsers::Vector{DataType} = [Int, Float64],
skiphead::Int=0, nrows::Union{Int, Nothing}=nothing)
read_csv(filename::AbstractString;
delim::Char=',', header::Bool=true, na::String="",
parsers::Vector{DataType} = [Int, Float64],
skiphead::Int=0, nrows::Union{Int, Nothing}=nothing)
```