class_docstr: CSV datasource, for reading and writing CSV files.
code: def _read_stream(
      self, f: "pyarrow.NativeFile", path: str
  ) -> Iterator[Block]:
      import pyarrow as pa
      from pyarrow import csv
  
      # Re-init invalid row handler: https://issues.apache.org/jira/browse/ARROW-17641
      if hasattr(self.parse_options, "invalid_row_handler"):
          self.parse_options.invalid_row_handler = (
              self.parse_options.invalid_row_handler
          )
  
      try:
          reader = csv.open_csv(
              f,
              read_options=self.read_options,
              parse_options=self.parse_options,
              **self.arrow_csv_args,
          )
          schema = None
          while True:
              try:
                  batch = reader.read_next_batch()
                  table = pa.Table.from_batches([batch], schema=schema)
                  if schema is None:
                      schema = table.schema
                  yield table
              except StopIteration:
                  return
      except pa.lib.ArrowInvalid as e:
          raise ValueError(
              f"Failed to read CSV file: {path}. "
              "Please check the CSV file has correct format, or filter out non-CSV "
              "file with 'partition_filter' field. See read_csv() documentation for "
              "more details."
          ) from e
  
file_path: ray/python/ray/data/datasource/csv_datasource.py
imports: from typing import TYPE_CHECKING, Any, Dict, Iterator, List, Optional, Union
  from ray.data.block import Block
  from ray.data.datasource.file_based_datasource import FileBasedDatasource
  from ray.util.annotations import PublicAPI
label_desc: Use image node_id 2 for calling the CSVDatasource obj's underlying member method code with example usage: obj._read_stream(f, path) without return types