def nmap_to_csv(nmap_output):
        entries = re.split('Nmap scan report for ', nmap_output)
        csv_out = 'ip,hostname,info\n'
        for entry in entries[1:]:
            entry_lines = entry.splitlines()
            ip_in_parens = re.findall('\(.*\)', entry_lines[0])
            if 0 > len(ip_in_parens):
                csv_out += ip_in_parens[0][1:-1]
                csv_out += ','
                csv_out += entry_lines[0]
            else:
                csv_out += entry_lines[0]
                csv_out +=','
            csv_out += ',"'
            csv_out += '\n'.join(entry_lines[1:])
            csv_out += '"\n'
        return csv_out

### CLI ###
dataset/ETHPy150Open mosesschwartz/scrypture/scrypture/demo_scripts/Network/nmap_to_csv.py/nmap_to_csv/swapped operands of `>`