File as input in python netaddr
<p>Im trying to supernet list of IP networks using netaddr in python.</p>

<p><strong>Code:</strong></p>

<pre><code>import netaddr
from netaddr import *
iplist = [IPNetwork('10.105.205.8/29'),IPNetwork('10.105.205.16/28'),IPNetwork('10.105.205.0/29')]
print '%s' % netaddr.cidr_merge(iplist)
</code></pre>

<p>**Output:**Which actually works.</p>

<pre><code>[IPNetwork('10.105.205.0/27')]
</code></pre>

<p>Can I provide the input from a file? which contains IP networks in CSV files?</p>

<p><strong>IP_Network.csv</strong></p>

<pre><code>8.35.196.0/23
8.35.196.0/24
8.35.197.0/24
8.35.198.0/23
8.35.198.0/24
8.35.199.0/24
8.35.200.0/21
8.35.200.0/23
8.35.200.0/24
8.35.201.0/24
8.35.202.0/23
</code></pre>

<p>I am not familiar with the netaddr module but to me it seems you are just building a list from inputs. If you have an input file with a network in each line, would this work:</p>

<pre><code>with open ("inputfile", "r") as fp:
    iplist = [IPNetwork(q) for q in fp.read().splitlines()]
</code></pre>

<p>Hannu</p>

python linux bash ip