Python and ArcGIS

In-Class Exercise: Parse Address Data

Goal

Write a Python program that will read strings in a provided format and parse out the individual data fields

Data Dictionary (fixed field width)

Field

First name

Last name

Street number

Street name

City

State

Zip

Zip + 4

Chars

10

20

5

25

20

2

5

4

 

For the data

����� Fred�������������� Smith128����������������� Main St����������� AltamontNY120090567

Output format:

First Name: Fred

Last Name: Smith

Street Number: 128

Street Name: Main St

City: Altamont

State: NY

Zip: 12009

Zip +4: 0567

 

Method:

1.   Download and unzip PythonParseAddressData.zip

2.   Run my small module ParseAddressData.py that reads AddressData.txt with a for loop

3.   Add lines of code to parse out and print the address components using Output Format above as your guide

4.   Hint: use the string slicing operators from this lecture