067AARON WAY 30043002500002599A 098 0670000017 129 672
067ABBA CT 30518000882000902A 025 11 0670163227 365 670
067ABBEY HILL RD 30024000100000299A 004 12 0670000027 276 667
067ABBEY LN SW30047004900005099A 052 0670000036 093 659
067ABBEY PARK WAY 30044000901000967A 043 0670161916 177 622
067ABBEY POINTE WAY 30024000103000176A 100 12 0670178087 235 667
067ABBIE KILGORE WAY 30052001314001487A 041 0670155595 096 649
067ABBOTT DR 30519002103002236A 129 0670176283 007 682
067ABBOTTS BRIDGE RD 30096003550003578E 096 04 0670128036 293 697
067ABBOTTS BRIDGE RD 30096003551003935O 056 04 0670128046 293 697
and this code...
dafile = 'gwinnett_streets_short.txt'
f = open(dafile, 'r')
for line in f:
line=line.strip('\r\n')
county_code=line[0:3]
street_name=line[3:30]
district_combo=line[85:3]
print county_code, '|' , street_name , '|' , district_combo , '|' , len(line), '|'
I get this output...
067 | AARON WAY | | 88 |
067 | ABBA CT | | 88 |
067 | ABBEY HILL RD | | 88 |
067 | ABBEY LN | | 88 |
067 | ABBEY PARK WAY | | 88 |
067 | ABBEY POINTE WAY | | 88 |
067 | ABBIE KILGORE WAY | | 88 |
067 | ABBOTT DR | | 88 |
067 | ABBOTTS BRIDGE RD | | 88 |
067 | ABBOTTS BRIDGE RD | | 88 |
If I change the slice for district_combo to
district_combo=line[85:]
The output is what I want...
067 | AARON WAY | 672 | 88 |
067 | ABBA CT | 670 | 88 |
067 | ABBEY HILL RD | 667 | 88 |
067 | ABBEY LN | 659 | 88 |
067 | ABBEY PARK WAY | 622 | 88 |
067 | ABBEY POINTE WAY | 667 | 88 |
067 | ABBIE KILGORE WAY | 649 | 88 |
067 | ABBOTT DR | 682 | 88 |
067 | ABBOTTS BRIDGE RD | 697 | 88 |
067 | ABBOTTS BRIDGE RD | 697 | 88 |
Why does the final slice have to be an open slice? Why can the slice not be like the previous slices in which it is a specified range of characters?
--
We are all slave to our own paradigm. -- Joshua Williams
-- http://mail.python.org/mailman/listinfo/python-list