Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add convert command #610

Merged
merged 17 commits into from
May 15, 2023
Merged

Add convert command #610

merged 17 commits into from
May 15, 2023

Conversation

nwagner84
Copy link
Member

@nwagner84 nwagner84 commented Apr 21, 2023

Examples

PICA+ to Plain

$ pica convert --from plus --to plain tests/snapshot/data/algebra.dat
001A $01250:01-07-88                                                                                                                                     
001B $01250:24-04-19$t15:55:35.000                                                                                                                       
001D $09999:17-01-09                                                                                                                                     
001U $0utf8                                                                                                                                              
001X $00                                                                                                                                                 
002@ $0Ts1                                                                                                                                               
003@ $0040011569
...

PICA+ to PICA XML

$ pica  convert --from plus --to xml tests/snapshot/data/algebra.dat
<?xml version="1.0" encoding="UTF-8"?>                                                                                                                   
<collection targetNamespace="info:srw/schema/5/picaXML-v1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="info:srw/schema/5/picaXML-v1.0">         
    <record>                                                                                                                                             
        <datafield tag="001A">                                                                                                                           
            <subfield code="0">1250:01-07-88</subfield>                                                                                                  
        </datafield>                                                                                                                                     
        <datafield tag="001B">                                                                                                                           
            <subfield code="0">1250:24-04-19</subfield>                                                                                                  
            <subfield code="t">15:55:35.000</subfield>                                                                                                   
        </datafield>                                                                                                                                     
        <datafield tag="001D">                                                                                                                           
            <subfield code="0">9999:17-01-09</subfield>                                                                                                  
        </datafield>
        ...
    </record>
</collection>

PICA+ to PICA JSON

pica convert --from plus --to json tests/snapshot/data/algebra.dat`
[[["001A",null,"0","1250:01-07-88"],[...],["070A","02","S","MACS","0","0000478"]]]

PICA+ to Binary PICA

echo -e "003@ \x1f0123456789\x1fab\x1e" | pica convert --from plus --to binary | hexdump -C
00000000  30 30 33 40 20 1f 30 31  32 33 34 35 36 37 38 39  |003@ .0123456789|
00000010  1f 61 62 1e 1d                                    |.ab..|
00000015

PICA+ to Import

$ echo -e "003@ \x1f0123456789\x1fab\x1e012A \x1fa123\x1e" | pica convert --from plus --to import | hexdump -C
00000000  1d 0a 1e 30 30 33 40 20  1f 30 31 32 33 34 35 36  |...003@ .0123456|
00000010  37 38 39 1f 61 62 0a 1e  30 31 32 41 20 1f 61 31  |789.ab..012A .a1|
00000020  32 33 0a                                          |23.|
00000023

@nwagner84 nwagner84 self-assigned this Apr 21, 2023
@nwagner84 nwagner84 linked an issue Apr 21, 2023 that may be closed by this pull request
@nwagner84 nwagner84 linked an issue Apr 21, 2023 that may be closed by this pull request
@nwagner84 nwagner84 added this to the v1.0.0 milestone Apr 21, 2023
@nwagner84 nwagner84 linked an issue Apr 21, 2023 that may be closed by this pull request
This was linked to issues Apr 21, 2023
@nwagner84 nwagner84 marked this pull request as ready for review May 15, 2023 09:06
@nwagner84 nwagner84 merged commit e41de20 into main May 15, 2023
@nwagner84 nwagner84 deleted the convert branch May 15, 2023 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant