I am trying to categorize columns and values (column=value) meaningfully from an input string using Python dictionaries.
input_string = "the status is processing and product subtypes are HL year 30 ARM and applicant name is Ryan"
I have created dictionaries of key value pairs. In the first scenario, the key is the column name. The value represents the lowest index of key found in input_string
.
Here is the dictionary of column names:
dict_columns = {'status': 4, 'product subtypes': 29, 'applicant name': 69}
In the above dictionary, 'status'
has the lowest index of 4
in the input_string
.
Similarly, here is the dictionary of values:
dict_values = {'processing': 14, 'hl': 50, 'year': 53, '30': 58, 'arm': 61, 'ryan': 87}
The question is:
How to get the expected ouput as:
list_parsed_values = ['processing', 'hl year 30 arm', 'ryan']
and the (optional) corresponding list of columns as:
list_parsed_columns = ['status', 'product subtypes', 'applicant name']
How to clearly distinguish the values in a list?