Created
January 19, 2020 08:10
-
-
Save Matts966/443e32680477cf476532598a0628fd82 to your computer and use it in GitHub Desktop.
.ris file to citation list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sys import stdin | |
| index = 0 | |
| finding_author = False | |
| author = "" | |
| finding_publish_year = False | |
| publish_year = "" | |
| etal = False | |
| for line in stdin: | |
| if line.startswith("TI"): | |
| index += 1 | |
| finding_author = True | |
| finding_publish_year = True | |
| elif finding_author and line.startswith("AU"): | |
| author = line.split()[2][:-1] + " " | |
| finding_author = False | |
| etal = False | |
| elif not finding_author and not etal and line.startswith("AU"): | |
| author += "et al., " | |
| etal = True | |
| elif finding_publish_year and line.startswith("PY"): | |
| publish_year = line.split()[2] | |
| finding_publish_year = False | |
| if not etal: | |
| author += ".," | |
| print(str(index) + ". " + author + publish_year) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment