import unicodecsv
from cStringIO import StringIO
from intelmq.lib.bot import Bot, sys
from intelmq.lib.message import Event
from intelmq.lib.utils import encode
from intelmq.bots import utils

class MalwareDomainListParserBot(Bot):

    def process(self):
        report = self.receive_message()

        if report:
            report = encode(report)
            
            columns = ["source_time", "source_url", "source_ip", "source_reverse_dns", "malware", "__IGNORE__", "source_asn"]

            for row in unicodecsv.reader(StringIO(report), encoding='utf-8'):
                event = Event()

                with open('/tmp/test.txt','a') as fp:
                    fp.write(str(row))

                for key, value in zip(columns, row):
                    
                    if key is "__IGNORE__":
                        continue
                    
                    if key is "source_time":
                        value = value.replace('_',' ')
                        value += " UTC"
                        
                    if key is "malware":
                        value = value.lower()
                        
                    event.add(key, value)
                    
                event.add('feed', 'malwaredomainslist')
                event.add('feed_url', 'http://www.malwaredomainlist.com/updatescsv.php')
                event.add('type', 'malware')    # FIXME
                
                event = utils.parse_source_time(event, "source_time")
                event = utils.generate_observation_time(event, "observation_time")
                event = utils.generate_reported_fields(event)
                    
                self.send_message(event)
        self.acknowledge_message()


if __name__ == "__main__":
    bot = MalwareDomainListParserBot(sys.argv[1])
    bot.start()

import unicodecsv
from cStringIO import StringIO
from intelmq.lib.bot import Bot, sys
from intelmq.lib.message import Event
from intelmq.lib.utils import encode
from intelmq.bots import utils

class MalwareDomainListParserBot(Bot):

    def process(self):
        report = self.receive_message()

        if report:
            report = encode(report)
            
            columns = ["source_time", "source_url", "source_ip", "source_reverse_dns", "malware", "__IGNORE__", "source_asn"]

            for row in unicodecsv.reader(StringIO(report), encoding='utf-8'):
                event = Event()

                for key, value in zip(columns, row):
                    
                    if key is "__IGNORE__":
                        continue
                    
                    if key is "source_time":
                        value = value.replace('_',' ')
                        value += " UTC"
                        
                    if key is "malware":
                        value = value.lower()
                        
                    event.add(key, value)
                    
                event.add('feed', 'malwaredomainslist')
                event.add('feed_url', 'http://www.malwaredomainlist.com/updatescsv.php')
                event.add('type', 'malware')    # FIXME
                
                event = utils.parse_source_time(event, "source_time")
                event = utils.generate_observation_time(event, "observation_time")
                event = utils.generate_reported_fields(event)
                    
                self.send_message(event)
        self.acknowledge_message()


if __name__ == "__main__":
    bot = MalwareDomainListParserBot(sys.argv[1])
    bot.start()

Update parser.py