Question: so i basically know what the Error means but i don't know why i'm getting it.I want to insert my cvs file into a table. Some of the rows are empty, thats why im using the if None...

The Error im getting:

File "C:\Users\Desktop\IngestData.py", line 64, in institutions
 cokey = temp[0]
TypeError: 'NoneType' object is not subscriptable

Hope somebody can help me!
Thank you in advance!

```
def institutions(cur):
    with open('persons.csv', 'r', encoding="utf-8") as g:
        #tempo = None
        reader = csv.reader(g)
        next(reader)
        for row in reader:
            if row[4] is None:
                break
            else:
                cur.execute("SELECT COKEY FROM countries WHERE Name = (%s)", [row[4]])
                temp = cur.fetchone()
                cokey = temp[0]
                cur.execute("""INSERT INTO institutions (Name,cokey) VALUES (%s,%s)
                            ON CONFLICT DO NOTHING;""",[row[3],cokey])

```

Answer: 
Here's a quick and dirty solution for you:

Walk through every element of the array recursively and if you've not seen an element set it to null (unsetting it doesn't work for some reason). Then filter the resulting sub-arrays. 

```php
$array = [[0, 1, 2, 3, 4], [1, 2, 3, 4, 6]];
$seen = [];
array_walk_recursive($array, function (&$v) use (&$seen) {
    if (!array_key_exists($v, $seen) {
       $seen[$v] = true;
    } else {
       $v = null;
    }
});
$final = array_map('array_filter', $array);

```
```

$serialize=array_map('serialize',$array);
$unique=array_unique($serialize);

$result=array_map('unserialize',$uniue);

print_r($result);

```