I am working on a networking project and I need to output a CSV file for a database consumption. I am getting a list of computer hostnames, interface names, IPs and MACAddresses. Unfortunately they are not formatted the best and I need to rearrange the data to produce a CSV file. My output lists the hostname and the interface name and then lists hostname and IP/MAC as listed below. Some machines have more interfaces than others so I can't just count down and copy that to a new cell. The order of interface name will match up to the IPs so I just need to figure out how to merge lines. My ideal output would be hostname, Interface Name, IP, MAC. I am just not sure how to go about rearrange the data. Any suggestions?
I hope to get something like this.
Code:
computer1,InterfaceName 1
computer1,InterfaceName 2
computer1,InterfaceName 3
computer1,InterfaceName 4
computer1,{"127.0.0.1"} 00:00:00:00:00:01
computer1,{"127.0.0.2"} 00:00:00:00:00:02
computer1,{"127.0.0.3"} 00:00:00:00:00:03
computer1,{"127.0.0.4"} 00:00:00:00:00:04
computer2,InterfaceName 1
computer2,InterfaceName 2
computer2,{"127.0.0.1"} 00:00:00:00:00:01
computer2,{"127.0.0.2"} 00:00:00:00:00:02
I hope to get something like this.
Code:
computer1,InterfaceName 1,127.0.0.1, 00:00:00:00:00:01
computer1,InterfaceName 2,127.0.0.2, 00:00:00:00:00:02
computer1,InterfaceName 3,127.0.0.3, 00:00:00:00:00:03
computer1,InterfaceName 4,127.0.0.4, 00:00:00:00:00:04
computer2,InterfaceName 1,127.0.0.1, 00:00:00:00:00:01
computer2,InterfaceName 2,127.0.0.2, 00:00:00:00:00:02