[vox-tech] Finding the right tool for parsing

Alex Mandel tech_dev at wildintellect.com
Sat Jan 19 13:50:08 PST 2008


I've got a big text file to parse(example below)
Now I was about to figure out how to parse what I need from this file 
using python since it's what I'm used to but I realized it was going to 
be hard and some of you seem to love sed, awk etc. Which I have no idea 
how to use.

So how would I:

The only pattern I can find to parse on is a:

.
Map data ©2008 Tele Atlas

at the end of each entry signifies the start of the next entry consistently.

Sample of What I need is the 1st 2 lines of each section parsed into one 
line and separated by a special character(not a comma):
618 Lessley Pl, Davis, CA 95616
2.0 mi (about 9 mins)
->
618 Lessley Pl, Davis, CA 95616 ; 2.0 mi (about 9 mins)

Sample Output:

618 Lessley Pl, Davis, CA 95616
2.0 mi (about 9 mins)
1.	Head north on Lessley Pl toward Lehigh Dr	335 ft
2.	Turn left at Lehigh Dr	0.1 mi
3.	Turn right at Colgate Dr	0.2 mi
4.	Turn left at L St	0.2 mi
5.	Turn right at 5th St	0.6 mi
6.	Turn left at B St	427 ft
7.	Turn right at 4th St	367 ft
8.	Turn left at University Ave	499 ft
9.	Turn right at 3rd St	0.2 mi
10.	Turn left at E Quad	0.2 mi
11.	Turn right at Peter J Shields Ave/Shields Ave	0.2 mi
	1 Shields Ave, Davis, CA 95616
.		
Map data ©2008 Tele Atlas
	618 Lessley Pl, Davis, CA 95616
2.0 mi (about 9 mins)
1.	Head north on Lessley Pl toward Lehigh Dr	335 ft
2.	Turn left at Lehigh Dr	0.1 mi
3.	Turn right at Colgate Dr	0.2 mi
4.	Turn left at L St	0.2 mi
5.	Turn right at 5th St	0.6 mi
6.	Turn left at B St	427 ft
7.	Turn right at 4th St	367 ft
8.	Turn left at University Ave	499 ft
9.	Turn right at 3rd St	0.2 mi
10.	Turn left at E Quad	0.2 mi
11.	Turn right at Peter J Shields Ave/Shields Ave	0.2 mi
	1 Shields Ave, Davis, CA 95616
.		
Map data ©2008 Tele Atlas
	1600 Amphitheatre Pkwy, Mountain View, CA 94043
105 mi (about 1 hour 54 mins)
1.	Head west on Amphitheatre Pkwy toward Garcia Ave	0.5 mi
2.	Merge onto US-101 N via the ramp to San Francisco	4.7 mi
3.	Exit onto CA-114/Willow Rd toward Fremont/State Hwy 84 E	1.0 mi
4.	Slight right toward Bayfront Expy/CA-84	495 ft
5.	Slight right at Bayfront Expy/CA-84
Continue to follow CA-84
	8.4 mi
6.	Merge onto I-880 N via the ramp to Oakland	22 mi
7.	Slight right at I-980 E (signs for I-980/State Hwy 24/Walnut Creek) 
1.5 mi
8.	Take the exit onto I-580 W toward San Francisco	5.9 mi
9.	Continue on I-80 E (signs for Vallejo/Sacramento)
Partial toll road
	60 mi
10.	Take exit 72 for Richards Blvd	0.3 mi
11.	Turn right at Richards Blvd (signs for Davis)	0.3 mi
12.	Slight right to stay on Richards Blvd	0.2 mi
13.	Turn left at 1st St	0.3 mi
14.	Turn right at A St	0.2 mi
15.	Turn left at 3rd St	0.1 mi
16.	Turn left at E Quad	0.2 mi
17.	Turn right at Peter J Shields Ave/Shields Ave	0.2 mi
	1 Shields Ave, Davis, CA 95616
.		
Map data ©2008 Tele Atlas


Anyone want to take a stab at it,
Thanks,
Alex


More information about the vox-tech mailing list