I am working with csv file that contains a header with each node and a corresponding row with each node, with each data field corresponding to the difference between the two nodes like so:
| Blank | 4 | 38 | 71 | 90 | 94 | ... | 8545 |
|---|---|---|---|---|---|---|---|
| 4 | 0 | 1280 | 1762 | 1406 | 1589 | ... | 1017 |
| 38 | 1280 | 0 | 681 | 202 | 385 | ... | 1433 |
| 71 | 1762 | 681 | 0 | 503 | 0 | ... | 0 |
| 90 | 1406 | 202 | 503 | 0 | 0 | ... | 1559 |
| 94 | 1589 | 385 | 0 | 0 | 0 | ... | 1742 |
| .. | .. | ... | ... | ... | ... | 0 | ... |
| 8545 | 1017 | 1433 | 0 | 1559 | 1742 | ... | 0 |
(in this context 0 means there is no connection, either because they are the same node or they are not joined)
I would like to change the layout so it instead resembles this:
| Node1 | Node2 | Distance |
|---|---|---|
| 4 | 4 | 0 |
| 4 | 38 | 1280 |
| 4 | 71 | 1762 |
And so on, including all nodes and their connections
Is there a pythonic way to carry this out?