Question: I have .csv dataset that has two columns, each column has nodes and a row of this file represents a relationship between the two nodes.
I want to use it for creating a graph using Python's networkx library but I could not figure out how to reach each cell of each column in a row. Here is my code.

```
import networkx as nx
import csv
G = nx.Graph()
with open('/pathToTheFile/edges.csv', newline='') as f:
    reader = csv.reader(f)
    counter = 0
    for row in reader:
        G.add_edge()#I will pass two nodes here to add an edge between them
        counter += 1
        if counter >= 65535:
            break

```

Answer: 
When you iterate through a csv reader, you get each row of the file as a list. So you can use indexing to access the 0th and 1st cell in a row and create an edge between them.

```
import networkx as nx
import csv
G = nx.Graph()
with open('csv-networkx.csv', newline='') as f:
    reader = csv.reader(f)
    counter = 0
    for row in reader: # row is a list of the cells in this row.
        G.add_edge(row[0], row[1])
        counter += 1
        if counter >= 65535:
            break

```
Since it's a .csv, you can split it with commas:

```
values = row.split(',')
# 1st column value in row:
values[0]
# 2nd column value in row
values[1]

```