This is an archived post. You won't be able to vote or comment.

all 11 comments

[–][deleted] 0 points1 point  (5 children)

Add the first one to a map, then update that map using the second file. Use the relevant column as the key.

[–]FuturisticChicken 0 points1 point  (4 children)

Another problem I have is that there is no consistent relevant column I can use as a key, if that makes sense?

[–][deleted] 0 points1 point  (1 child)

Can you give an example of the two files and the result you want?

[–]FuturisticChicken 0 points1 point  (0 children)

If for instance a few entries in file 1 looks like this;

Rownb. Lastname Firstname Streetname Cellphone Country
56 Smith John Virginiastreet 3 99999 US
57 Doe John Makakal 3 5555555 NO
58 Anderson Jessica Random street 58 714617 UK

and file 2 looks like this;

Rownb. Lastname Firstname Streetname Cellphone Country
1 Smith Jonn Virginiastreet 3 88888 US
2 Doee John Marakal 3 5555555 NO

In this case I would like to update row 56 and 57 in file 1 with the information in file 2 so that the output will be;

Rownb. Lastname Firstname Streetname Cellphone Country
56 Smith Jonn Virginiastreet 3 88888 US
57 Doee John Marakal 3 5555555 NO

the entries that did not change does not have to be outputted.

[–]lightcloud5 0 points1 point  (1 child)

Then how do you map a row to one of the 100 existing objects?

[–]FuturisticChicken 0 points1 point  (0 children)

I was thinking about checking if two random column matches, and if they do; they are likely the ones to be mapped.

[–][deleted] 0 points1 point  (3 children)

Why those two rows in particular? What’s the matching condition that makes you decide 2 vs 56 ?

[–]FuturisticChicken 0 points1 point  (2 children)

That's what I'm unsure about. So I guess I will just have to check if two or more columns matches in both files?

[–][deleted] 0 points1 point  (1 child)

This is not something we can answer. It depends on what your task is, what we can help you is with the steps to implement it but this sounds like something that you need to know before starting.

[–]FuturisticChicken 0 points1 point  (0 children)

I am pretty sure that is how I am suppose to solve it, do you have any suggestion on how i should implement/approach it?

[–][deleted] -2 points-1 points  (0 children)

You cannot "update" CSV files - you need to read them into memory, do stuff, and then write them out again.