[Tutor] Finding unique strings.

Mark Lawrence breamoreboy at gmail.com
Fri May 3 17:35:12 EDT 2019


On 03/05/2019 13:07, mhysnm1964 at gmail.com wrote:
> All,
> 
> I have a list of strings which has been downloaded from my bank. I am trying
> to build a program to find the unique string patterns which I want to use
> with a dictionary. So I can group the different transactions together. Below
> are example unique strings which I have manually extracted from the data.
> Everything after the example text is different. I cannot show the full data
> due to privacy.
> 
> WITHDRAWAL AT HANDYBANK
> 
> PAYMENT BY AUTHORITY
> 
> WITHDRAWAL BY EFTPOS
> 
> WITHDRAWAL MOBILE
> 
> DEPOSIT          ACCESSPAY
> 
> Note: Some of the entries, have an store name contained in the string
> towards the end. For example:
> 
> WITHDRAWAL BY EFTPOS 0304479 KMART 1075       CASTLE HILL 24/09
> 
> Thus I want to extract the KMART as part of the unique key. As the shown
> example transaction always has a number. I was going to use a test condition
> for the above to test for the number. Then the next word would be added to
> the string for the key.
> I tried to use dictionaries and managed to get unique first words. But got
> stuck at this point and could not work out how to build a unique keyword
> with multiple words. I hope someone can help.
> 
> Sean
> 

Please check out 
https://docs.python.org/3/library/collections.html#collections.defaultdict 
as I think it's right up your street.  Examples are given at the link  :)

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence



More information about the Tutor mailing list