Git Product home page Git Product logo

diff_csv's Introduction

diff_csv

You can extract only different elements between two CSV files which have the same structure by this module.

When comparing files, you can select multiple key columns to connect two CSV files.

You can also select specific columns to exclude from this comparision.

レイアウトが同じ2つのCSVファイルを比較し、値が更新された要素のみを抽出できるものが欲しくて作りました。

複数のカラムをキーにCSVファイルの各行を比較できるようになっています。

また、特定の列は比較対象から除外することもできるようになっています。

Requirement

  • pandas
  • numpy

Usage

before.csv

id,col1,col2,col3
1,abc,def,ghi
2,jkl,mno,pqr
3,stu,vwx,yz1

after.csv

id,col1,col2,col3
1,abc,def,ghi
2,jkl,MNO,pqr
4,234,567,890
5,ABC,DEF,GHI

Sample code is below.

from diff_csv.diff_csv import DiffCSV

diff = DiffCSV(
    {
        "before_csv": 'before.csv',
        "after_csv": 'after.csv',
        "key_cols": [0],
    }
)
print(diff.diffrences)

Outputs are below. (pandas DataFrame)

.   0 1_after 2_after 3_after 4_after update_flag
2         MNO             update
3                         delete
4  234    567     890     add
5  ABC    DEF     GHI     add

You can output differences to CSV.

diff.to_csv('output.csv')

Author

Linsence

diff_csv is under MIT license.

diff_csv's People

Watchers

Hiroki Takeda 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.