lib/polars/io.rb in polars-df-0.1.4 vs lib/polars/io.rb in polars-df-0.1.5

- old
+ new

@@ -57,11 +57,11 @@ # rows cannot be guaranteed. # @param encoding ["utf8", "utf8-lossy"] # Lossy means that invalid utf8 values are replaced with `�` # characters. When using other encodings than `utf8` or # `utf8-lossy`, the input is first decoded im memory with - # python. + # Ruby. # @param low_memory [Boolean] # Reduce memory usage at expense of performance. # @param rechunk [Boolean] # Make sure that all columns are contiguous in memory by # aggregating the chunks into a single array. @@ -449,11 +449,27 @@ row_count_name: row_count_name, row_count_offset: row_count_offset, ) end - # def read_avro - # end + # Read into a DataFrame from Apache Avro format. + # + # @param file [Object] + # Path to a file or a file-like object. + # @param columns [Object] + # Columns to select. Accepts a list of column indices (starting at zero) or a list + # of column names. + # @param n_rows [Integer] + # Stop reading from Apache Avro file after reading ``n_rows``. + # + # @return [DataFrame] + def read_avro(file, columns: nil, n_rows: nil) + if file.is_a?(String) || (defined?(Pathname) && file.is_a?(Pathname)) + file = Utils.format_path(file) + end + + DataFrame._read_avro(file, n_rows: n_rows, columns: columns) + end # Read into a DataFrame from Arrow IPC (Feather v2) file. # # @param file [Object] # Path to a file or a file-like object.