Code Monkey home page Code Monkey logo

join-object's Introduction

Join-Object

Join-Object LINQ Edition. Aims to provide the exact functionality of https://github.com/RamblingCookieMonster/PowerShell/blob/master/Join-Object.ps1 with much better performance. Initial testing shows at last 100 times faster.

PowerShell Gallery Downloads

CI System Environment Master Beta
AppVeyor Windows, Core preview, Ubuntu Build status Build status
Azure DevOps Windows Build Status Build Status
Azure DevOps Windows (Core) Build Status Build Status
Azure DevOps Ubuntu Build Status Build Status
Azure DevOps macOS Build Status Build Status

Explanation and usage Examples

See RamblingCookieMonster guide http://ramblingcookiemonster.github.io/Join-Object/ and Join-Object.Examples.ps1. And also Join-Object.Tests.ps1.

# Left Object Example
$PSCustomObject = @(
    [PSCustomObject]@{ID = 1 ; Sub = 'S1' ; IntO = 6}
    [PSCustomObject]@{ID = 2 ; Sub = 'S2' ; IntO = 7}
    [PSCustomObject]@{ID = 3 ; Sub = 'S3' ; IntO = $null}
)
# Right Object Example (DataTable)
$DataTable = [Data.DataTable]::new('Test')
$null = $DataTable.Columns.Add('IDD', [System.Int32])
$null = $DataTable.Columns.Add('Name')
$null = $DataTable.Columns.Add('Junk')
$null = $DataTable.Columns.Add('IntT', [System.Int32])
$null = $DataTable.Rows.Add(1, 'foo', 'AAA', 123456)
$null = $DataTable.Rows.Add(3, 'Bar', 'S3', $null)
$null = $DataTable.Rows.Add(4, 'D', $null, $null)

# Join the 2 together ("Left Join" in this example)
Join-Object -Left $PSCustomObject -Right $DataTable -LeftJoinProperty 'ID' -RightJoinProperty 'IDD' -ExcludeRightProperties 'Junk' -Prefix 'R_' | Format-Table

<# Output
    ID Sub IntO R_Name R_IntT
    -- --- ---- ------ ------
    1 S1     6 foo    123456
    2 S2     7
    3 S3       Bar
#>

Additional functionality

  • Supports DataTable object type.
  • Additional parameters -ExcludeLeftProperties and -ExcludeRightProperties.
  • Additional parameter -PassThru, If added changes the original Left Object
  • Converts DBNull to $null
  • -RightJoinScript and -LeftJoinScript parameters to support custom joining scripts.
  • -RightJoinProperty and -LeftJoinProperty supports multiple Properties (String Array) to join on multiple columns.
  • -DataTable parameter to output as "DataTable".
  • -AddKey can be used with "-Type AllInBoth" to add a column containing the joining key.
  • -AllowColumnsMerging Allow duplicate columns in the Left and Right Objects, will overwrite the conflicting Left data with the Right data (Ignoring Nulls), Supported only on DataTable output for now.
  • -Comparer allow use of custom [EqualityComparer].

Missing functionality

  • -Type "AllInRight".

To do

  • Noting for now, You can open an Issues if something is needed.

Install

From repository (Recommended)

Install-Module -Name Join-Object -Scope CurrentUser

From GitHub Branch (For testing)

$Uri = 'https://raw.githubusercontent.com/ili101/Join-Object/master/Install.ps1'; & ([Scriptblock]::Create((irm $Uri))) -FromGitHub $Uri

Contributing

If you fund a bug or added functionality or anything else just fork and send pull requests. Thank you!

Changelog

CHANGELOG.md

Default and supported join modes

Join Type Linq mode LeftMultiMode supported RightMultiMode supported PassThru
OnlyIfInBoth Join DuplicateLines DuplicateLines Not Supported
AllInLeft GroupJoin DuplicateLines SingleOnly, DuplicateLines, SubGroups SingleOnly, SubGroups
AllInBoth FullGroupJoin SingleOnly, DuplicateLines, SubGroups SingleOnly, DuplicateLines, SubGroups Not Supported

* Bold signifies the default setting.

More PowerShell stuff

https://github.com/ili101/PowerShell

join-object's People

Contributors

ili101 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.