[librecat-dev] Export into JSON using perl

Tiago Murakami trmurakami at gmail.com
Fri Mar 8 11:32:50 CET 2019


Awesome, thanks!

On Fri, Mar 8, 2019 at 6:18 AM Nicolas Steenlant <Nicolas.Steenlant at ugent.be>
wrote:

> You can just use the unix split command:
>
>
> https://unix.stackexchange.com/questions/74146/split-file-into-multiple-small-files-separate-by-the-newline-symbol
>
> or with Perl and Catmandu:
>
> use Catmandu;
>
> my $importer = Catmandu->importer('MARC',file => 'input/2records.seq' ,
> type => 'ALEPHSEQ');
> my $fixer = Catmandu->fixer('fixesCatmandu.txt');
> my $count = 0;
>
> $fixer->fix($importer->benchmark)->each(sub {
>   my $rec = $_[0];
>   Catmandu->exporter('JSON', file => "/tmp/out_${count}.json")-
> >add($rec);
>   $count++;
> });
>
> Greets,
> Nicolas
>
>
> On Thu, 2019-03-07 at 13:05 -0300, Tiago Murakami wrote:
> > Hi,
> >
> > Thanks! It is possible to, for each json, create one file?
> >
> >
> > On Thu, Mar 7, 2019 at 12:40 PM Nicolas Franck <
> > Nicolas.Franck at ugent.be> wrote:
> > >
> > > > On 7 Mar 2019, at 16:30, Tiago Murakami <trmurakami at gmail.com>
> > > wrote:
> > > >
> > > > Hi,
> > > >
> > > > I made my first perl script to convert MARC ALEPHSEQ into JSON. I
> > > can import and convert to JSON using myfixes. How I can export into
> > > JSON files?
> > > >
> > > > Thanks,
> > > >
> > > > =================
> > > >
> > > > use Catmandu;
> > > >
> > > > my $importer = Catmandu->importer('MARC',file =>
> > > 'input/2records.seq' , type => 'ALEPHSEQ');
> > > > my $fixer    = Catmandu->fixer('fixesCatmandu.txt');
> > > > my $exporter = Catmandu->exporter('JSON');
> > >
> > > my $exporter = Catmandu->exporter('JSON', file =>
> > > "/path/to/my/file.json");
> > >
> > > or direct the output of stdout to a file
> > >
> > > >
> > > > $exporter->add_many(
> > > >      $fixer->fix($importer->benchmark)
> > > > );
> > > >
> > > > =================
> > > >
> > > > --
> > > > Tiago Murakami
> > > > _______________________________________________
> > > > 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/
> > >
> >
> >
> > _______________________________________________
> > 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/
>


-- 
Tiago Murakami
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.uni-bielefeld.de/mailman2/unibi/public/librecat-dev/attachments/20190308/e4512e5f/attachment.html>


More information about the librecat-dev mailing list