'Parses given lines from airodump-ng CSV file.
Returns tuple: List of targets and list of clients.'

def parse_csv(self, filename):

    if (not os.path.exists(filename)):
        return ([], [])
    targets = []
    clients = []
    try:
        hit_clients = False
        with open(filename, 'rb') as csvfile:
            targetreader = csv.reader((line.replace('\x00', '') for line in csvfile), delimiter=',')
            for row in targetreader:
                if (len(row) < 2):
                    continue
                if (not hit_clients):
                    if (row[0].strip() == 'Station    MAC'):
                        hit_clients = True
                        continue
                    if (len(row) < 14):
                        continue
                    if (row[0].strip() == 'BSSID'):
                        continue
                    enc = row[5].strip()
                    wps = False
                    if ((enc.find('WPA') == (-1)) and (enc.find('WEP') == (-1))):
                        continue
                    if (self.RUN_CONFIG.WEP_DISABLE and (enc.find('WEP') != (-1))):
                        continue
                    if (self.RUN_CONFIG.WPA_DISABLE and self.RUN_CONFIG.WPS_DISABLE and (enc.find('WPA') != (-1))):
                        continue
                    if ((enc == 'WPA2WPA') or (enc == 'WPA2    WPA')):
                        enc = 'WPA2'
                        wps = True
                    if (len(enc) > 4):
                        enc = enc[4:].strip()
                    power = int(row[8].strip())
                    ssid = row[13].strip()
                    ssidlen = int(row[12].strip())
                    ssid = ssid[:ssidlen]
                    if (power < 0):
                        power += 100
                    t = Target(row[0].strip(), power, row[10].strip(), row[3].strip(), enc, ssid)
                    t.wps = wps
                    targets.append(t)
                else:
                    if (len(row) < 6):
                        continue
                    bssid = re.sub('[^a-zA-Z0-9:]', '', row[0].strip())
                    station = re.sub('[^a-zA-Z0-9:]', '', row[5].strip())
                    power = row[3].strip()
                    if (station != 'notassociated'):
                        c = Client(bssid, station, power)
                        clients.append(c)
    except IOError as e:
        print 'I/O    error({0}):    {1}'.format(e.errno, e.strerror)
        return ([], [])
    return (targets, clients)
