[librecat-dev] Vacuum fix on keys?

Tobias Bülte tobias.buelte at hbz-nrw.de
Wed Sep 13 17:57:26 CEST 2023


I was not sure about the behaviour in Catmandu.

But since we implemented fix as transformation language in metafacture,
I tested it there and with MF it works:

https://metafacture.org/playground/?flux=inputFile%0A%7C+open-file%0A%7C+as-records%0A%7C+decode-json%0A%7C+fix%28transformationFile%29%0A%7C+encode-json%28prettyPrinting%3D%22true%22%29%0A%7C+print%0A%3B&transformation=remove_field%28%22%22%29&data=%7B%0A++++%22Hello%22%3A+%22World%22%2C%0A++++%22%22+%3A+%22This+is+an+empty+key%22%0A%7D

Seems that MF and Catmandu behave differently with this regard.

Am 13.09.23 um 15:18 schrieb Nicolas Franck:
> @Tobias: if only that were true. Maybe it has two, or three spaces?
>
> Another solution would be to copy the input record to another and
> specify all of the valid keys by name, and then run vacuum on that copy.
> This way the weird keys are gone.
>
>> On 13 Sep 2023, at 15:02, Tobias Bülte <tobias.buelte at hbz-nrw.de> wrote:
>>
>> Wouldn't remove_field("") do the trick?
>>
>>
>> Am 13.09.23 um 14:34 schrieb Peil, Vitali:
>>> Hi all,
>>>
>>> I came across some bad data ;-). Tried to fix this with the vacuum fix. The data I have includes empty field names which I want to clean.
>>>
>>> with the vacuum fix:
>>> $ echo '[{"ok": 1, "empty": "", "":"some bad data"}]' | catmandu convert to JSON --fix "vacuum()"
>>> Output: [{"":"some bad data","ok":1}]
>>>
>>> but I would expect as output
>>> [{"ok":1}]
>>>
>>> Is this a bug in the vacuum fix? Is there another way doing this?
>>>
>>> Best,
>>> Vitali
>>>
>>>
>>> _______________________________________________
>>> 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/


More information about the librecat-dev mailing list