Data Cleaning - Capstone

Hello q-bies, 

 

I am currently completing the Capstone project from the KX academy and I’ve hit a bit of a snag on 2.3 - Create a function  extractBrokerId  that will return the brokerId as a long when
passed an exchange message.** 

 

extractBrokerId “CME-TSLA20200920C1700-709” should return a value of 709, while
extractBrokerId “ISE-708-TSLA20200920C1700” should return a value of 708. 

 

I have been struggling to return the correct broker ID from the strings provided - has anyone had anyone else had difficulty on this and could point me to the material which helped them complete this part? The link to string manipulation on the project itself isn’t providing much clarity. 

 

Thanks, 

Conor

Hi,

Does something like this help you:  extractBrokerId:{ “J”$x (CMEISE!2 1)`$first x:“-” vs x  };

x:“-” vs x  >> split x by “-” and store this list as x

`$first x  >> this will be the exchange code .e.g CME and cast to symbol

(CMEISE!2 1)  >> dictionary mapping exchange to brokerId field location in exchange message
“J”$x >> the dictionary location mapping is used to reference that item in list x, to return the  broker id value, then cast the string to long