Oct-07-2019, 05:16 PM
(Oct-07-2019, 04:56 PM)ichabod801 Wrote: That line is too long IMHO. I would do it like this:
if "Classification:" in filtered_artifacts_item_1_0: splitresponse__response_value = filtered_artifacts_item_1_0[0].split('Classification:') else: (filtered_artifacts_item_1_0, "Sent with BlackBerry Work")[0].strip()From this code, it appears filtered_artifacts_item_1_0 is a list. In the fourth line there, you put it in a tuple with "Sent with BlackBerry Work". Then you get the [0] index of that tuple, which is filtered_artifacts_item_1_0. Then you try to strip that, which causes an error, because (as the error says) you can't strip a list.
My guess is that you mean to do something else when you make that tuple? If that's right, what are you trying to do?
The input data is an email, we are wanting to strip out everything except 2 pieces of data from this email a Yes/No and a unique ID value, the body of the email will begin with either Yes or No, the goal is to split at a string that occurs after the Yes or No in the email body. The second piece of data will be the unique ID value, this will come after a string of "*****************" towards the end of the email, followed by the unique ID value.
The reason we are wanting to split is because there are two values we are trying to capture out of the email. the first being the Yes or No at the beginning, so the first "split" will be at either "Classification:" or "Sent with BlackBerry Work" to capture the Yes or No from the first position in the body of the email. The second split later after this first split is done, we have a second split occurring later in the body of the email after "*****************", we are wanting to strip everything left of this value and only retain the value after it (the unique ID value).
Example emails below, the "filtered_artifacts_item_1_0 is the email message itself:
email example 1):
Yes
Sent with BlackBerry Work
(www.blackberry.com)
___________________________________________________________________
From:
Date:
To:
Cc:
Subject:
*****************
BA2337C9-9E57-4BED-A984-8B28EFA6B403@@notable@@47e96bf35r92eabc107470cee79f27e9
email example 2):
Yes
Classification: Internal
___________________________________________________________________
From:
Date:
To:
Cc:
Subject:
*****************
BA2337C9-9E57-4BED-A984-8B28EFA6B403@@notable@@47e96bf35r92eabc107470cee79f27e9