Hi everyone,
I have a problem, and I would like to ask for help.
I have two text files.
The first one contains multiple lines in this format:
characterstring : hash
characterstring1 : hash1
characterstring2: hash2
The second one is in this format:
hash: plaintext
hash2 : plaintext2
hash3 : plaintext3
I am looking for a way to replace in file 1 all the hashes by their plain text versions contained in the file 2.
The result should be a third file in this format:
characterstring1:plaintext1
characterstring2:plaintext2
characterstring3:plaintext3
Can anyone help me to achieve this? If possible with a python script
Thanks
3 Likes
There are some sample python script available, if you can develop your own using these will do the work!
https://pythontesting.net/python/regex-search-replace-examples/
4 Likes
Sadly, I still struggle to achieve what Iβm looking for
1 Like
Shunya
5
Hi @Dracaryu , You can use pandas for that!
Something like a vlook operation.
Eg: pokeman is a csv file say
with data in the below
Now Try this
pokemon_names.map(pokemon_types)
pokemon_names = pd.read_csv("pokemon.csv", usecols= ["Pokemon"], squeeze= True)
pokemon_types = pd.read_csv("pokemon.csv", index_col= "Pokemon", squeeze= True).to_dict()
pokemon_names.map(pokemon_types).head()
Does this help you?
1 Like
I am not used to that, but I will try.
Thank you for your help.
1 Like
Shunya
7
How long is the text with the hash?
530k for the first one.
174k for the second one.
1 Like
Shunya
9
Oh, you can try pandas, But it might be less efficient.
Here, I found some more helpful links.
This might actually help you.
1 Like
Thanks. I will check that.
1 Like