SciRuby / daru-io

daru-io is a plugin gem to the existing daru gem, which aims to add support to Importing DataFrames from / Exporting DataFrames to multiple formats.
http://www.rubydoc.info/github/athityakumar/daru-io/master/
MIT License
24 stars 9 forks source link

Better distinction between method arguments in Importers #53

Open athityakumar opened 7 years ago

athityakumar commented 7 years ago

Suggested by @zverok in PR #52

Currently, owing to the restriction due to automatic monkey-patching of daru-io modules into daru, the Importers are designed like this.

#! Usage from daru
df = Daru::DataFrame.read_csv(path, col_sep: ' ', other_opts)

#! is linked to daru-io like
inst = Daru::IO::Importers::CSV.read(path)
df = inst.call(col_sep: ' ', other_opts)

But, daru-io could use better set of arguments for methods, to ensure that a file is read only ONCE, and then called for dataframe with other options.

df = Daru::DataFrame.read_csv(path, col_sep: ' ', other_opts)

#! should rather be linked to daru-io like
inst = Daru::IO::Importers::CSV.read(path, col_sep: ' ')
df = inst.call(other_opts)

In general, all file parsing arguments and path should be provided in the read method, while post-reading arguments can be provided in call method.