Score:0

Compare two lists, file1 and file2, get the IDs in file2 present in the usernames in file1

ru flag

Please I need help...

I have two lists, file1 and file2. The list file1 has only usernames, while file2 has the same usernames but with additional columns (username|private yes or no|id).

Basically I need to know the ID (which is in file2) of the usernames which are in file1.

file1 (50k lines):

user1
user2
user3

...

file2 (500k lines):

user1|YES|8125958
user2|YES|4825195
user3|YES|8757159
user4|NO|5185761

...

user535733 avatar
cn flag
This seems like a homework question.
pLumo avatar
in flag
What is the expected output? What did you try?
ru flag
@pLumo I tried several examples on the internet and none worked... The file1 only has the usernames that I would like to extract from the IDs that are in the file2. file2 has the same usernames as file1, but has more usernames. The file1 would be just what I really wanted...
ru flag
@user535733 Well, that seems difficult to solve =/
user535733 avatar
cn flag
If it is a homework problem, then look at the tools you have discussed in class: grep, find, cut, arrays, and other shell tools. Or regular expressions. Or dicts or slicing if using python. There are other tools for perl, for go, for C, for vala.
pLumo avatar
in flag
Tell us **exactly** what you tried (the commands) and what was not working, and what is your expected output (the output that matches your example input). Don't do that in comments but edit your question instead please. Then we will be able to help you.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.