unibrementypo3auto/bib/shorten_authorname.py

11 lines
376 B
Python
Raw Normal View History

2023-05-15 19:20:33 +02:00
def shorten_authorname(input: str) -> str:
temp = input.split(",")
name: str = temp[0].lstrip().rstrip() + str(",")
temp = temp[1].lstrip().rstrip().split(" ")
for i in temp:
if len(i) > 0:
first_letter = i.upper()[0]
if first_letter.isalpha() is True:
name += str(" ") + first_letter + str(".")
return name