Last active
August 29, 2015 14:03
-
-
Save ianfhunter/43599d30384b9b7aa0c6 to your computer and use it in GitHub Desktop.
Longest Anime Title
This file contains 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
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