I have IPv4 blocks in the CIDR notation form. These blocks are divided on the basis of city I want to merge them one level up I mean till region level e.g
12.17.230.48|12.178.230.63|US|Texas|Temple
12.178.230.64|12.178.230.95|US|Texas|Abilene
12.178.230.96|12.178.230.111|US|Texas|Jayton
12.178.230.112|12.178.230.119|US|Texas|Wichita Falls
12.178.230.120|12.178.230.127|US|Texas|Mansfield
12.178.230.128|12.178.230.159|US|Texas|Waco (Bellmead)
12.178.230.160|12.178.230.167|US|Texas|Irving
12.178.230.168|12.178.230.175|US|Texas|Fort Worth
12.178.230.176|12.178.230.183|US|Texas|Alvarado
12.178.230.184|12.178.230.191|US|Texas|Weatherford
12.178.230.192|12.178.230.199|US|Texas|Haltom City
12.178.230.200|12.178.230.207|US|Texas|Fort Worth (Diamond Hill - Jarvis)
12.178.230.208|12.178.230.223|US|Texas|Fort Worth
12.178.230.224|12.178.230.231|US|Texas|Coppell
12.178.230.232|12.178.230.239|US|Texas|Lubbock
here All goes to Texas so I want to merge all those blocks in to one like this
start_ip_of_first_range|end_ip_of_last_range_of_same_region|US|Texas
Though I tried to this but looks like I was even violating IPv4 addresses fundamental rule
Please suggest any formula ?