Skip to content

Commit

Permalink
Modify ELRMileages._parse_mileage() for .collect_mileage_file()
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeqfu committed Feb 2, 2023
1 parent 994e9f3 commit 0bedc9b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pyrcs/line_data/elr_mileage.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,12 @@ def _parse_mileage(mileage):
temp_mileage.append(m1)
mileage_note.append(m2.strip() + ' (Alternative)')
else:
temp_mileage.append(m.strip(' ').replace(' ', '.'))
if re.match(r'\d+,\d+', m):
temp_mileage.append(m.strip(' ').replace(',', '.'))
else:
temp_mileage.append(m.strip(' ').replace(' ', '.'))
mileage_note.append('')

miles_chains = temp_mileage.copy()
temp_mileage = [mile_chain_to_mileage(m) for m in temp_mileage]

Expand Down Expand Up @@ -344,9 +348,11 @@ def _parse_node(self, node):

link_cols = [x for x in conn_nodes.columns if re.match(r'^(Link_\d)', x)]
link_nodes = conn_nodes[link_cols].applymap(self._uncouple_elr_mileage)
link_elr_mileage = pd.concat(
[pd.DataFrame(link_nodes[col].values.tolist(), columns=[col + '_ELR', col + '_Mile_Chain'])
for col in link_cols], axis=1, sort=False)

dat = [
pd.DataFrame(link_nodes[col].values.tolist(), columns=[col + '_ELR', col + '_Mile_Chain'])
for col in link_cols]
link_elr_mileage = pd.concat(dat, axis=1, sort=False)

parsed_node_and_conn = pd.concat([prep_node, conn_nodes, link_elr_mileage], axis=1)

Expand Down

0 comments on commit 0bedc9b

Please sign in to comment.