AlenkaF commented on a change in pull request #12543:
URL: https://github.com/apache/arrow/pull/12543#discussion_r834222139
##########
File path: python/pyarrow/_csv.pyx
##########
@@ -299,6 +352,48 @@ cdef class ParseOptions(_Weakrefable):
parsing (because of a mismatching number of columns).
It should accept a single InvalidRow argument and return either
"skip" or "error" depending on the desired outcome.
+
+ Examples
+ --------
+
+ Defining an example file from bytes object:
+
+ >>> import io
+ >>> s = b'''animals;n_legs;entry
+ ... Flamingo;2;2022-03-01
+ ... # Comment here:
+ ... Horse;4;2022-03-02
+ ... Brittle stars;5;2022-03-03
+ ... Centipede;100;2022-03-04'''
+
+ Read the data from a file skipping rows with comments
+ and defining the delimiter:
+
+ >>> from pyarrow import csv
+
+ >>> class InvalidRowHandler:
+ ... def __init__(self, result):
+ ... self.result = result
+ ... def __call__(self, row):
+ ... if row.text.startswith("# "):
+ ... return self.result
+ ... else:
+ ... return 'error'
+ ...
+ >>> skip_handler = InvalidRowHandler('skip')
Review comment:
Yes, that would be better. Will try it out, thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]