Longest Anime Title
import re | |
# To be used with anime-titles.dat from AniDB, replace with your own path | |
# created: Thu Jul 10 02:00:05 2014 | |
# <aid>|<type>|<language>|<title> | |
# type: 1=primary title (one per anime), 2=synonyms (multiple per anime), 3=shorttitles (multiple per anime), 4=official title (one per language) | |
def is_ascii(s): | |
return all(ord(c) < 128 for c in s) | |
def to_alphanum(s): | |
return ''.join(ch for ch in s if ch.isalnum()) | |
f = open("C:\Users\Ian\Downloads\\anime-titles.dat\\anime-titles.dat","r") | |
longest = "" | |
spaceless = "" | |
for line in f: | |
data = line.split("|") | |
if is_ascii(data[3]):# == "1": | |
if len(data[3]) > len(longest): | |
longest = data[3] | |
if (len( to_alphanum(data[3])) > len(spaceless) ): | |
spaceless = to_alphanum(data[3]) | |
print "\nlongest with whitespace: \n" + longest | |
print "\nlongest without whitespace:\n " + spaceless | |
input("...") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment