You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to follow the example creating a custom importer and mapper class.
require 'zizia'
class MyImporter
def initialize(csv_file)
@csv_file = csv_file
raise "Cannot find expected input file #{csv_file}" unless File.exist?(csv_file)
end
def import
attrs = {
collection_id: 'id', # pass a collection id to the record importer and all records will be added to that collection
depositor_id: 'id', # pass a Hyrax user_key here and that Hyrax user will own all objects created during this import
deduplication_field: 'identifier' # pass a field with a persistent identifier (e.g., ARK) and it will check to see if a record with that identifier already
} # exists, update its metadata if so, and only if it doesn't find a record with that identifier will it make a new object.
file = File.open(@csv_file)
parser = Zizia::CsvParser.new(file: file)
record_importer = Zizia::HyraxRecordImporter.new(attributes: attrs)
Zizia::Importer.new(parser: parser, record_importer: record_importer).import
file.close # unless a block is passed to File.open, the file must be explicitly closed
end
end
my task:
namespace :basic_import do
desc 'Ingest sample data'
task sample: [:environment] do
csv_file = Rails.root.join('app', 'importers', 'csv.csv')
ModularImporter.new(csv_file).import
end
end
my command to run the import task:
rake basic_import:sample --trace
However i got this error
I understand what is the error talking about, but could not figure it out why. This CSV file has been imported successfully from UI.
The text was updated successfully, but these errors were encountered:
I was trying to follow the example creating a custom importer and mapper class.
my task:
my command to run the import task:
However i got this error
I understand what is the error talking about, but could not figure it out why. This CSV file has been imported successfully from UI.
The text was updated successfully, but these errors were encountered: