Skip to content

error when no key precised #3

@MainHanzo

Description

@MainHanzo
Contributor

the tool works well when we have a id precised by user as the key. However I think when the user doesn't use the '--key' option, it's not working as expected.

for example:
----1.csv----
"""id,name,age
1,Cleo,5
2,Pancakes,2"""

----2.csv----
"""id,name,age
1,Cleo,5
2,Pancakes,3"""

and we launch with no key option :
csv-diff 1.csv 2.csv
we will get:
"2 rows added, 2 rows removed

2 rows added

id: 1
name: Cleo
age: 5

id: 2
name: Pancakes
age: 2

2 rows removed

id: 1
name: Cleo
age: 5

id: 2
name: Pancakes
age: 4

"

while i expect this:
"
1 row added, 1 row removed
1 row added:
id:2
name: Pancakes
age: 2
1 row removed:
id: 2
name: Pancakes
age: 4

"

the problem is caused because that the hash of the line is stored as a hash object, and even two lines are the same content, the memo locations are different. So they are different objects.

I have corrected this feature, if you like, I can upload it through a pull request.

Activity

simonw

simonw commented on Feb 29, 2020

@simonw
Owner

Thanks - please do open a pull request for this!

MainHanzo

MainHanzo commented on Mar 6, 2020

@MainHanzo
ContributorAuthor

Thanks - please do open a pull request for this!

PR Done! :)

added a commit that references this issue on Oct 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @simonw@MainHanzo

        Issue actions

          error when no key precised · Issue #3 · simonw/csv-diff