Skip to content

Conversation

quinnj
Copy link
Member

@quinnj quinnj commented Apr 21, 2020

This implements #522. It allows providing two different callbacks:

  • invalidrow: a callback that takes a single Integer representing
    the row number where an invalid state was detected (not enough columns
    parsed or more columns than expected were detected)

  • invalidcell: a callback called when an error occurs parsing a
    user-provided type (Int, Float64, Bool, Date, DateTime, or Time); the
    callback should take 5 arguments: 1) the type attempted while parsing,

  1. a string of the cell where parsing failed, 3) a Parsers.jl code
    return code value that encodes events/states that occurred while
    parsing, 4) the row the invalid cell was on, and 5) the column the
    invalid cell was on.

Providing an invalidrow or invalidcell function forces
silencewarnings=true for invalid rows or cells, respectively, i.e. no
warning will be printed if an error callback function is provided.

If strict=true is provided, invalidcell will not be invoked.

This PR includes a simple test, but no docs yet.

This implements #522. It allows providing two different callbacks:

* `invalidrow`: a callback that takes a single `Integer` representing
the row number where an invalid state was detected (not enough columns
parsed or more columns than expected were detected)

* `invalidcell`: a callback called when an error occurs parsing a
user-provided type (Int, Float64, Bool, Date, DateTime, or Time); the
callback should take 5 arguments: 1) the type attempted while parsing,
2) a string of the cell where parsing failed, 3) a Parsers.jl `code`
return code value that encodes events/states that occurred while
parsing, 4) the row the invalid cell was on, and 5) the column the
invalid cell was on.

Providing an `invalidrow` or `invalidcell` function forces
`silencewarnings=true` for invalid rows or cells, respectively, i.e. no
warning will be printed if an error callback function is provided.

If `strict=true` is provided, `invalidcell` will not be invoked.

This PR includes a simple test, but no docs yet.
@codecov
Copy link

codecov bot commented Apr 21, 2020

Codecov Report

Merging #618 into master will increase coverage by 1.25%.
The diff coverage is 89.65%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #618      +/-   ##
==========================================
+ Coverage   82.83%   84.09%   +1.25%     
==========================================
  Files           9        9              
  Lines        1643     1804     +161     
==========================================
+ Hits         1361     1517     +156     
- Misses        282      287       +5     
Impacted Files Coverage Δ
src/file.jl 84.75% <88.88%> (-0.24%) ⬇️
src/rows.jl 97.82% <100.00%> (ø)
src/write.jl 88.74% <0.00%> (+6.10%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1eddc33...26a65f5. Read the comment docs.

@quinnj
Copy link
Member Author

quinnj commented Jun 26, 2020

Closing in favor of the approach in #656

@quinnj quinnj closed this Jun 26, 2020
@quinnj quinnj deleted the jq/invalidcallbacks branch June 26, 2020 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant