Skip to content

Instantly share code, notes, and snippets.

@AndrewTheTM
Last active May 30, 2024 19:43
Show Gist options
  • Select an option

  • Save AndrewTheTM/d4132ff4e50a2be5a380d26d79e59550 to your computer and use it in GitHub Desktop.

Select an option

Save AndrewTheTM/d4132ff4e50a2be5a380d26d79e59550 to your computer and use it in GitHub Desktop.
This scans the transit PRN output of a Cube Voyager transit load step and returns a data frame of the from-zone, to-zone, and number of trips.
def list_bad_zones(input_file):
with open(input_file, 'r') as fr:
lines = fr.readlines()
lines = [line.rstrip('\n') for line in lines]
chk = re.compile('.*([0-9]+\.[0-9]*) Trips for I\=([0-9]+) to J\=([0-9]+), but no path.*')
lines = pd.DataFrame({'INPUT': [l for l in lines if chk.match(l)]})
lines['trips'] = lines['INPUT'].apply(lambda x: float(chk.match(x)[1]))
lines['i'] = lines['INPUT'].apply(lambda x: chk.match(x)[2])
lines['j'] = lines['INPUT'].apply(lambda x: chk.match(x)[3])
return lines[['i', 'j', 'trips']]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment