Skip to content

Instantly share code, notes, and snippets.

@pschanely
Created February 8, 2020 05:19
Show Gist options
  • Save pschanely/93f54161c4bda3a3bf93fe7f7d598d29 to your computer and use it in GitHub Desktop.
Save pschanely/93f54161c4bda3a3bf93fe7f7d598d29 to your computer and use it in GitHub Desktop.
Shared via CrossHair Playground
from typing import List
def csv_last_column(lines: List[str]) -> List[str]:
'''
Gets you the last column from a csv.
We use CrossHair to confirm our index arithmetic is correct.
pre: all(',' in line for line in lines)
post: __return__ == [line.split(',')[-1] for line in lines]
'''
return [line[line.rindex(',') + 1:] for line in lines]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment