Your input string is not really CSV. Instead your input contains the column name in each row. If your input looks like this:
NAME: "2801 chassis", DESCR: "2801 chassis, Hw Serial#: xxxxxxx, Hw Revision: 6.0",PID: CISCO2801 , VID: V03 , SN: xxxxxxxxx
NAME: "2802 wroomer", DESCR: "2802 wroomer, Hw Serial#: xxxxxxx, Hw Revision: 6.0",PID: CISCO2801 , VID: V03 , SN: xxxxxxxxx
NAME: "2803 foobars", DESCR: "2803 foobars, Hw Serial#: xxxxxxx, Hw Revision: 6.0",PID: CISCO2801 , VID: V03 , SN: xxxxxxxxx
The simplest you can do is probably to filter out the column names first, in the whole file. That would then give you a CSV file you can parse. But that assumes each line has the same columns in the same order.
However, if the data is not that consistent, you might want to parse it based on the names. Perhaps it looks like this:
NAME: "2801 chassis", PID: CISCO2801 , VID: V03 , SN: xxxxxxxxx, DESCR: "2801 chassis, Hw Serial#: xxxxxxx, Hw Revision: 6.0"
NAME: "2802 wroomer", DESCR: "2802 wroomer, Hw Serial#: xxxxxxx, Hw Revision: 6.0",PID: CISCO2801 , VID: V03 , SN: xxxxxxxxx
NAME: "2803 foobars", VID: V03 ,PID: CISCO2801 ,SN: xxxxxxxxx
Or something. In that case I'd parse each line by looking for the first ':', split out the column head from that, then parse the value (including looking for quotes), and then continue with the rest of the line. Something like this (completely untested code):
def parseline(line):
result = {}
while ':' in line:
column, rest = line.split(':',1)
column = column.strip()
rest = rest.strip()
if rest[0] in ('"', '"'): # It's quoted.
quotechar = rest[0]
end = rest.find(quotechar, 1) # Find the end of the quote
value = rest[1:end]
end = rest.find(',', end) # Find the next comma
else: #Not quoted, just find the next comma:
end = rest.find(',', 1) # Find the end of the value
value = rest[0:end]
result[column] = value
line = rest[end+1:]
line.strip()
return result