0

I have the following CSV:

PORT,STATUS,PROTOCOL,DESCRIP,
Gi0/0,admin down,down,,
Gi1/0/1,up,up,Device1,
Gi1/0/2,up,up,Device2,
Gi1/0/3,up,up,Device3,
Gi1/0/4,up,up,Device4,

and I want to read each line and assign a value for each column. For example:

Read first line {
Port1 = Gi1/0/1
Status1 = up
description1 = Device1
}
Read second line {
Port2 = Gi1/0/2
Status2 = up
description2 = Device2
}

and so on..

I have the following code using pandas but for DESCRIPTION, I am getting this error:

Traceback (most recent call last):
<div class="st_column _description">"""+str(desc1)+"""</div>
TypeError: can only concatenate str (not "float") to str

But for PORT and STATUS it's working. here is my code:

df = pd.read_csv("/var/www/html/test.csv")
port1 = (df.loc[1, 'PORT'])
desc1 = (df.loc[1, 'DESCRIP'])
status1 = (df.loc[1, 'STATUS'])

The problem is the slash in port names. It can't pass /

0 Answers0