This is my code. I used re to convert more than one spaces into a single space.
Then i split the lines and convert into list format.
When all the fields contains data, then i am getting the expected result.
If any of the field is blank(Designation field in the last record), I am not getting the expected output.
['EMP GRADE DESIGNATION SALARY ', 'Amy C Software Enginner 6K', 'Rock A Admin 8K', 'Paige D 9K']
Expected Output: (Additional spaces for Designation field for the last record)
['EMP GRADE DESIGNATION SALARY ', 'Amy C Software Engineer 6K', 'Rock A Admin 8K', 'Paige D <Addtional space here> 9K']
Then i split the lines and convert into list format.
When all the fields contains data, then i am getting the expected result.
If any of the field is blank(Designation field in the last record), I am not getting the expected output.
import re inp1 = '''EMP GRADE DESIGNATION SALARY Amy C Software Engineer 6K Rock A Admin 8K Paige D 9K''' temp = re.sub(' +', ' ', inp1) lista = temp.splitlines () print(lista)Output
['EMP GRADE DESIGNATION SALARY ', 'Amy C Software Enginner 6K', 'Rock A Admin 8K', 'Paige D 9K']
Expected Output: (Additional spaces for Designation field for the last record)
['EMP GRADE DESIGNATION SALARY ', 'Amy C Software Engineer 6K', 'Rock A Admin 8K', 'Paige D <Addtional space here> 9K']