Comments (3)
To test if a CSV.Source
is done, I would use
Data.isdone(s, row, col)
but otherwise, eof(s.io)
should work fine too.
- There's an internal
CSV.STATE
variable of typeRef{CSV.ParsingState}
.CSV.ParsingState
is an enum with values
@enum ParsingState None Delimiter EOF Newline
Basically, each call to CSV.parsefield
implicitly sets this CSV.STATE
variable with the state of parsing when the parsing was finished:
None
: the default stateDelimiter
: parsing encountered a delimiter character which ended theCSV.parsefield
functionEOF
: parsing encountered the EOFNewline
: parsing encountered a newline which caused parsing to stop
- Currently there is no way to "skip" a field, though I have some notes jotted down somewhere with some considerations around doing something like this. I'll try to dig them up and post them here and maybe see how much work it would take to get it working. For now, though, what you're doing is best practice (just parse a string and continue on).
from csv.jl.
Thanks, this works fine. Could you consider adding API functions eof
and eol
, ideally with a CSV.Source
as their argument? (I am assuming that eventually the state will be migrated into CSV.Source
to avoid globals, but I could be mistaken as I did not study the source deeply).
from csv.jl.
On current master, you can now do CSV.File(file; kwargs...)
which returns a lazy-materializing row-iterator. You could accomplish the original goal by doing something like:
struct CustomType
a::Int
b::Float64
c::String
end
customtypes = CustomType[]
for row in CSV.File(file; kwargs...)
if should_keep(row.a)
push!(customtypes, CustomType(row.a, row.b, row.c)
end
end
In this case, only the a
, b
, and c
column values will actually be parsed from the csv file.
from csv.jl.
Related Issues (20)
- burntsushi's issue HOT 1
- Multithreaded parsing error should be warning HOT 7
- Error reading CSV - missing lines HOT 2
- Load error with Parsers.Options HOT 4
- Configurable max inline string length
- Precompilation issue in Ubuntu 22.04.2 LTS (libLLVM-14jl.so (unknown line)) HOT 14
- Formatting issues in examples
- Cannot compile this package on Julia 1.9.1 in Ubuntu 22.04 container HOT 3
- "Missing" Values HOT 2
- Keyword `decimal` not respected for AbstractFloats in CSV.write()
- Can't transfer CSV.jl v0.10.11 from Windows to Linux HOT 2
- CSV.write somehow cannot write file with name `con.csv` in Windows?! HOT 5
- Add Zenodo badge to README HOT 6
- Segfault on Julia 1.9 on Intel Sapphire Rapids during precompilation
- `bufsize` of `write` is defined to be length of row but actually cells
- can not read the csv with large cells written by itself HOT 1
- Formatting broken on Examples page in documentation HOT 2
- CSV.jl fails to precompile on Ubuntu server, v0.10.5 and up. HOT 2
- Error on CSV.read attempt HOT 4
- `emptyvalue` keyword option
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from csv.jl.