Using Python to parse data

Python scripts can be used to add returns between multiple strings that are separated with unequal blank spaces. The resulting list will have the extra spaces excised. This task is accomplished with the split function.

Working in Python 2.7, follow these steps.

1. Assign a name to the text to be parsed. In this example, we call the text 'set1'

>>> set1 = "Lopez Lee Smith"

2. Create a second set (here it's called 'names'), and then use the split function with no setting between the parentheses that follow the function name. The name of what we're parsing precedes the split function. >>> names = set1.split()

3. Python will understand a reference to a single member of a set with a plural name. Use this command: >>> for name in names:

. . . and then press return and print the reference to the set with the singular name. print name

Press return twice to get the results:

Lopez Lee Smith >>>