lib/remi/data_subject/csv_file.rb in remi-0.2.35 vs lib/remi/data_subject/csv_file.rb in remi-0.2.36

- old
+ new

@@ -51,10 +51,12 @@ # Returns a Remi::DataFrame def to_dataframe # Assumes that each file has exactly the same structure result_df = nil extract.each_with_index do |filename, idx| + filename = filename.to_s + @logger.info "Converting #{filename} to a dataframe" processed_filename = preprocess(filename) csv_df = Daru::DataFrame.from_csv processed_filename, @csv_options csv_df[@filename_field] = Daru::Vector.new([filename] * csv_df.size, index: csv_df.index) if @filename_field @@ -69,19 +71,10 @@ end def extractor=(arg) - case arg - when Extractor::SftpFile, Extractor::LocalFile, Extractor::S3File - @extractor = arg - when String - @extractor = Extractor::LocalFile.new(path: arg) - when Regexp - raise "Adding regex matching to local files would be easy, not done yet" - else - raise "Unknown extractor of type #{arg.class}: #{arg}" - end + @extractor = arg.respond_to?(:extract) ? arg : Extractor::LocalFile.new(remote_path: arg.to_s) end # Only going to support single file for now def source_filename raise "Multiple source files detected" if extract.size > 1