GithubHelp home page GithubHelp logo

winebarrel / jljoin Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 28 KB

Read two NDJSON files and combine lines with common member values.

License: MIT License

Makefile 2.71% Rust 97.29%
rust ndjso jsonlines json

jljoin's Introduction

jljoin

Read two NDJSON files and combine lines with common member values.

NOTE: FILE1 and FILE2 must be sorted by the value of the join member. (cf. jlsort)

Build Status

Installation

brew install winebarrel/jl/jljoin

Usage

Usage: jljoin [OPTIONS] FILE1 FILE2

Options:
    -k, --key KEY       JSON key to join
    -1, --key1 KEY1     JSON key to join of FILE1
    -2, --key2 KEY2     JSON key to join of FILE2
    -m, --merge PRIORITY_FILENUM (1 or 2)
                        Merge the paired JSON
        --allow-no-key  Allow no key
    -v, --version       Print version and exit
    -h, --help          Print usage and exit
% cat a.ndjson
{"id": 1, "sub_id": 11, "file":"ndjson1", "val":"both"}
{"id": 2, "sub_id": 21, "file":"ndjson1", "val":"both/multi 1"}
{"id": 2, "sub_id": 22, "file":"ndjson1", "val":"both/multi 1"}
{"id": 3, "sub_id": 31, "file":"ndjson1", "val":"both/multi 2"}
{"id": 4, "sub_id": 41, "file":"ndjson1", "val":"only 1"}
{"id": 6, "sub_id": 62, "file":"ndjson1", "val":"both/multi"}
{"id": 6, "sub_id": 61, "file":"ndjson1", "val":"both/multi"}

% cat b.ndjson
{"id": 1, "sub_id": 11, "file":"ndjson2", "val":"both"}
{"id": 2, "sub_id": 21, "file":"ndjson2", "val":"both/multi 1"}
{"id": 3, "sub_id": 31, "file":"ndjson2", "val":"both/multi 2"}
{"id": 3, "sub_id": 32, "file":"ndjson2", "val":"both/multi 2"}
{"id": 5, "sub_id": 51, "file":"ndjson2", "val":"only 2"}
{"id": 6, "sub_id": 62, "file":"ndjson2", "val":"both/multi"}
{"id": 6, "sub_id": 61, "file":"ndjson2", "val":"both/multi"}

% jljoin -k id a.ndjson b.ndjson
[{"file":"ndjson1","id":1,"sub_id":11,"val":"both"},{"file":"ndjson2","id":1,"sub_id":11,"val":"both"}]
[{"file":"ndjson1","id":2,"sub_id":21,"val":"both/multi 1"},{"file":"ndjson2","id":2,"sub_id":21,"val":"both/multi 1"}]
[{"file":"ndjson1","id":2,"sub_id":22,"val":"both/multi 1"},{"file":"ndjson2","id":2,"sub_id":21,"val":"both/multi 1"}]
[{"file":"ndjson1","id":3,"sub_id":31,"val":"both/multi 2"},{"file":"ndjson2","id":3,"sub_id":31,"val":"both/multi 2"}]
[{"file":"ndjson1","id":3,"sub_id":31,"val":"both/multi 2"},{"file":"ndjson2","id":3,"sub_id":32,"val":"both/multi 2"}]
[{"file":"ndjson1","id":6,"sub_id":62,"val":"both/multi"},{"file":"ndjson2","id":6,"sub_id":62,"val":"both/multi"}]
[{"file":"ndjson1","id":6,"sub_id":62,"val":"both/multi"},{"file":"ndjson2","id":6,"sub_id":61,"val":"both/multi"}]
[{"file":"ndjson1","id":6,"sub_id":61,"val":"both/multi"},{"file":"ndjson2","id":6,"sub_id":62,"val":"both/multi"}]
[{"file":"ndjson1","id":6,"sub_id":61,"val":"both/multi"},{"file":"ndjson2","id":6,"sub_id":61,"val":"both/multi"}]

% jljoin -k id -m 1 a.ndjson b.ndjson
{"file":"ndjson1","id":1,"sub_id":11,"val":"both"}
{"file":"ndjson1","id":2,"sub_id":21,"val":"both/multi 1"}
{"file":"ndjson1","id":2,"sub_id":22,"val":"both/multi 1"}
{"file":"ndjson1","id":3,"sub_id":31,"val":"both/multi 2"}
{"file":"ndjson1","id":3,"sub_id":31,"val":"both/multi 2"}
{"file":"ndjson1","id":6,"sub_id":62,"val":"both/multi"}
{"file":"ndjson1","id":6,"sub_id":62,"val":"both/multi"}
{"file":"ndjson1","id":6,"sub_id":61,"val":"both/multi"}
{"file":"ndjson1","id":6,"sub_id":61,"val":"both/multi"}

Related Links

jljoin's People

Contributors

winebarrel avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.