I am looking to extract a list of tuples from the following string:
text='''Consumer Price Index:
+0.2% in Sep 2020
Unemployment Rate:
+7.9% in Sep 2020
Producer Price Index:
+0.4% in Sep 2020
Employment Cost Index:
+0.5% in 2nd Qtr of 2020
Productivity:
+10.1% in 2nd Qtr of 2020
Import Price Index:
+0.3% in Sep 2020
Export Price Index:
+0.6% in Sep 2020'''
I am using 'import re' for the process.
The output should be something like: [('Consumer Price Index', '+0.2%', 'Sep 2020'), ...]
I want to use a re.findall function that produces the above output, so far I have this:
re.findall(r"(:\Z)\s+(%\Z+)(\Ain )", text)
Where I am identifying the characters prior to ':', then the characters prior to '%' and then the characters after 'in'.
I'm really just clueless on how to continue. Any help would be appreciated. Thanks!