import pandas as pd

# text file is tab separated, but some lines fail to be read because of incorrect formating
# these are about 200 lined, and there are 20 000 lines which are parsed
# out of these correctly parsed lines I'll extract those domains that are classified as: 
# attackpage(attack_page)	|	malicious	|	malware	|fastflux	|	zeus	|	botnet	| ransomware

df = pd.read_csv("http://mirror1.malwaredomains.com/files/domains.txt", sep='\t', skiprows=(0,1,2,3), error_bad_lines=False, header=None)
#df.to_csv("malware_domains_tab_sep_text.csv")


#df = pd.read_csv("malware_domains_tab_sep_text.csv", usecols=['date', 'domain', 'type'])
allowed_types = ['attackpage', 'malware', 'malicious', 'fastflux', 'zeus', 'botnet', 'ransomware']

df = df.loc[df['type'].isin(allowed_types)]
df.to_csv("malware_domains_tab_sep_text_allowed_types.csv")