(filename)
return (targets, clients)
Parses given lines from airodump-ng CSV file.
        Returns tuple: List of targets and list of clients.
Parses given lines from airodump-ng CSV file.
        Returns tuple: List of targets and list of clients.
Parses given lines from airodump - ng CSV file . Returns tuple : List of targets and list of clients .
def parse_csv(filename):
    """
        Parses given lines from airodump-ng CSV file.
        Returns tuple: List of targets and list of clients.
    """
    global RUN_CONFIG
    if not os.path.exists(filename): return ([], [])
    try:
        f = open(filename, 'r')
        lines = f.read().split('\n')
        f.close()
    except IOError: return ([], [])
    
    hit_clients = False
    targets = []
    clients = []
    for line in lines:
        if line.startswith('Station MAC,'): hit_clients = True
        if line.startswith('BSSID') or line.startswith('Station MAC') or line.strip() == '': continue
        if not hit_clients: # Access points
            c = line.split(', ', 13)
            if len(c) <= 11: continue
            cur = 11
            c[cur] = c[cur].strip()
            if not c[cur].isdigit(): cur += 1
            if cur > len(c) - 1: continue
            
            ssid = c[cur+1]
            ssidlen = int(c[cur])
            ssid = ssid[:ssidlen]
            
            power = int(c[cur-4])
            if power < 0: power += 100
            
            enc = c[5]
            # Ignore non-WPA/WEP networks.
            if enc.find('WPA') == -1 and enc.find('WEP') == -1: continue
            if RUN_CONFIG.WEP_DISABLE and enc.find('WEP') != -1: continue
            if RUN_CONFIG.WPA_DISABLE and RUN_CONFIG.WPS_DISABLE and enc.find('WPA') != -1: continue
            enc = enc.strip()[:4]
            
            t = Target(c[0], power, c[cur-2].strip(), c[3], enc, ssid)
            targets.append(t)
        else: # Connected clients
            c = line.split(', ')
            if len(c) < 6: continue
            bssid   = re.sub(r'[^a-zA-Z0-9:]', '', c[0])
            station = re.sub(r'[^a-zA-Z0-9:]', '', c[5])
            power   = c[3]
            if station != 'notassociated':
                c = Client(bssid, station, power)
                clients.append(c)
    return (targets, clients)
def parse_csv ( filename ) : global RUN_CONFIG if not os . path . exists ( filename ) : return ( [ ] , [ ] ) try : f = open ( filename , 'r' ) lines = f . read ( ) . split ( '\n' ) f . close ( ) except IOError : return ( [ ] , [ ] ) hit_clients = False targets = [ ] clients = [ ] for line in lines : if line . startswith ( 'Station MAC,' ) : hit_clients = True if line . startswith ( 'BSSID' ) or line . startswith ( 'Station MAC' ) or line . strip ( ) == '' : continue if not hit_clients : # Access points c = line . split ( ', ' , 13 ) if len ( c ) <= 11 : continue cur = 11 c [ cur ] = c [ cur ] . strip ( ) if not c [ cur ] . isdigit ( ) : cur += 1 if cur > len ( c ) - 1 : continue ssid = c [ cur + 1 ] ssidlen = int ( c [ cur ] ) ssid = ssid [ : ssidlen ] power = int ( c [ cur - 4 ] ) if power < 0 : power += 100 enc = c [ 5 ] # Ignore non-WPA/WEP networks. if enc . find ( 'WPA' ) == - 1 and enc . find ( 'WEP' ) == - 1 : continue if RUN_CONFIG . WEP_DISABLE and enc . find ( 'WEP' ) != - 1 : continue if RUN_CONFIG . WPA_DISABLE and RUN_CONFIG . WPS_DISABLE and enc . find ( 'WPA' ) != - 1 : continue enc = enc . strip ( ) [ : 4 ] t = Target ( c [ 0 ] , power , c [ cur - 2 ] . strip ( ) , c [ 3 ] , enc , ssid ) targets . append ( t ) else : # Connected clients c = line . split ( ', ' ) if len ( c ) < 6 : continue bssid = re . sub ( r'[^a-zA-Z0-9:]' , '' , c [ 0 ] ) station = re . sub ( r'[^a-zA-Z0-9:]' , '' , c [ 5 ] ) power = c [ 3 ] if station != 'notassociated' : c = Client ( bssid , station , power ) clients . append ( c ) return ( targets , clients )