import re
pattern = re.compile(r"(^[^-]*-[^-]*)-[^-,]*")
with open('out.csv', encoding='utf-8') as f:
for row in f.readlines():
m = pattern.match(row)
if m:
print(m.group(1))
out.csv
https://www.abcde.com/-0w69e7e1w00-AIUEO
https://www.abcde.com/-0w69e7e9w70-Kakikukeko
https://www.abcde.com/-0w08e1e0w00-SA Shi Su Se So
https://www.abcde.com/-0w69e7e1w70-TA Chi Tsu Te to
https://www.abcde.com/-0w69e6e2w54-What is it
Recommended Posts