[librecat-dev] Error when processing the same file twice
Patrick Hochstenbach
Patrick.Hochstenbach at UGent.be
Wed Nov 28 10:31:52 CET 2018
Hello Georg
I can’t repeat the error on my machine with a simplified version of your script. I use Catmandu 1.09 and Catmandu::MARC 1.231.
Can you run the ‘test.pl’ script in the attachement and see if you sill get the errors you report?
Patrick
> On 27 Nov 2018, at 21:39, Mayr-Duffner, Georg <georg.mayr-duffner at wu.ac.at> wrote:
>
> Hello,
>
> I‘m trying to set up a web service (with dancer2) that does some Catmandu transformations and I‘m hopelessly stuck. I try to first do a MARC to JSON conversion to get some data out of a MARC input file (which in the end will go into a MongoDB) and then the same input file should be processed again in order to output an enriched MARC file. I can run one or the other but when I try to process both I get an error
>
> Can't locate object method "new" via package "Catmandu::Exporter::MARC" at /Users/gduffner/perl5/perlbrew/perls/perl-5.26.2/lib/site_perl/5.26.2/Catmandu/Env.pm line 219, <GEN2> line 12.
>
> Could you please help me track that down?
>
> Here’s the code of the subroutine:
>
> post '/cleanupMarc' => sub {
> my $sigel = param('paketSigel');
> my $type = param('inputFileType');
> my $packagemonth = param('packageMonth');
>
> my $input = request->upload('inputFile');
> my $uploaddir = path(config->{appdir}, 'uploads');
> mkdir $uploaddir if not -e $uploaddir;
> my $inputpath = path($uploaddir, $input->basename);
> $input->copy_to($inputpath);
>
> my $dldir = path(config->{public_dir}, 'downloads');
> mkdir $dldir if not -e $dldir;
>
> # marc2json
> my $jsonOutput = "$dldir/output1.json";
>
> my $jsonImporter = Catmandu->importer('MARC', file => $inputpath);#, type => $type);
>
> my $jsonFixer = Catmandu::Fix->new(
> variables => { sigel => $sigel, },
> fixes => ['fixfiles/IDs2json.fix'],
> );
> my $jsonExporter = Catmandu->exporter('JSON', file => $jsonOutput);
> my $fixed_jsonImporter = $jsonFixer->fix($jsonImporter);
> $jsonExporter->add_many($fixed_jsonImporter->benchmark);
> $jsonExporter->commit;
> undef($jsonExporter);
>
> # marc2marc
> my $marcOutput = "$dldir/output.mrc";
> my $marcImporter = Catmandu->importer('MARC', file => $inputpath);#, type => $type);
> my $marcFixer = Catmandu::Fix->new(
> variables => { sigel => $sigel,
> MARC2ISO => 'fixfiles/marc2iso3166H.csv',
> ISO2MARC => 'fixfiles/iso3166H2marc.csv',
> today => '20181122',},
> fixes => ['fixfiles/ebook.fix'],
> );
> my $marcExporter = Catmandu->exporter('MARC', file => $marcOutput);
> my $fixed_marcImporter = $marcFixer->fix($marcImporter);
> $marcExporter->add_many($fixed_marcImporter->benchmark);
> $marcExporter->commit;
> undef($marcExporter);
>
> redirect('/');
> };
>
> Thank you very much!
>
> Best regards
> Georg
>
>
>
> _______________________________________________
> librecat-dev mailing list
> - send list mails to librecat-dev at lists.uni-bielefeld.de
> - to unsubscribe or change options, visit https://lists.uni-bielefeld.de/mailman2/cgi/unibi/listinfo/librecat-dev
> - project website: http://librecat.org/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: camel.mrc
Type: application/octet-stream
Size: 6591 bytes
Desc: camel.mrc
URL: <http://lists.uni-bielefeld.de/mailman2/unibi/public/librecat-dev/attachments/20181128/c10198bd/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.pl
Type: text/x-perl-script
Size: 595 bytes
Desc: test.pl
URL: <http://lists.uni-bielefeld.de/mailman2/unibi/public/librecat-dev/attachments/20181128/c10198bd/attachment.bin>
More information about the librecat-dev
mailing list