Git Product home page Git Product logo

Comments (5)

patric-r avatar patric-r commented on August 20, 2024 1

@puddleoasis why not submit a PR?

from csv-diff.

simonw avatar simonw commented on August 20, 2024

This doesn't seem impossibly difficult to add... it could work by allowing users to specify the --key option multiple times

$ csv-diff one.csv two.csv --key=id --key=secondary

Part of the work would be teaching the CSV loading function to work with compound keys and create the internal ID as a tuple of values:

rows = [dict(zip(headings, line)) for line in fp]
if key:
keyfn = lambda r: r[key]
else:
keyfn = lambda r: hashlib.sha1(json.dumps(r, sort_keys=True).encode("utf8"))
return {keyfn(r): r for r in rows}

The human_text() function would then need to learn how to display a compound ID.

from csv-diff.

DavidUnderdown avatar DavidUnderdown commented on August 20, 2024

Thanks Simon,

I must admit that I was forgetting that our CSVs do typically have a URI per row too which is unique, so we could use that for purposes of getting a diff. May still be useful for others though.

For human_text(), perhaps some way of passing in a formatting string? In Python terms we'd want something likef"{r['lettercode']} {r['series']}/{r['piece']}/{r['item']} image {r['ordinal']}"

from csv-diff.

maxwelllc avatar maxwelllc commented on August 20, 2024

Seconding this, I'd find this very useful. As best as I can find, there are no other similar libraries that allow for composite keys, but I already use and am very happy with this package.

from csv-diff.

puddleoasis avatar puddleoasis commented on August 20, 2024

Hi @simonw I've made progress on this feature and would like to share. Would you grant me write access?

from csv-diff.

Related Issues (20)

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.