[Tutor] Finding unique strings.

mhysnm1964 at gmail.com mhysnm1964 at gmail.com
Sat May 4 04:48:43 EDT 2019


Mark and all,

Thanks for the link to the different dictionaries. The book which was
recommended I have already got and read which doesn't answer my question.
The structure of the CSV file is:

Account no, date, transaction description (what I am trying to build unique
keys from), credit, debit, serial and transaction type.

I have already loaded the cSV file into a list. Thus why I did not show any
code.  I will review the page provided and if I have more questions which
are going to e more than likely. I will come back using the same bat
channel.

Sean 

-----Original Message-----
From: Tutor <tutor-bounces+mhysnm1964=gmail.com at python.org> On Behalf Of
Mark Lawrence
Sent: Saturday, 4 May 2019 7:35 AM
To: tutor at python.org
Subject: Re: [Tutor] Finding unique strings.

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

_______________________________________________
Tutor maillist  -  Tutor at python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor



More information about the Tutor mailing list