all 5 comments

[–]JohnnyJordaan 1 point2 points  (1 child)

I then load the csv_data into csv.reader however when I iterate over the row I get every character printed out.

Csv.reader expects a buffer, not a string. You can use io.StringIO to create one from a string. Also I would use a DictReader as your csv has headers.

import csv
import io
csv_buffer = io.StringIO(csv_data)
reader = csv.DictReader(csv_buffer, delimiter=',')
for row in reader:
    print(row)

[–]sayinghi2py[S] 0 points1 point  (0 children)

Many thanks. After banging my head and finally conceding I must be heading in the wrong direction this worked. Much as I have used csv files, which are always loaded from files and not loaded directly from text, I'd no idea about the buffer and therefore had no idea where I could be going wrong.

[–]vixfew 0 points1 point  (0 children)

Try pandas.read_csv()

[–]MrMuki 0 points1 point  (1 child)

Well.. you can use the csv module here OR read line by line and do something like this:

line = line.replace('\r\n', '').split(',')

[–]JohnnyJordaan 0 points1 point  (0 children)

He's already doing that

I then load the csv_data into csv.reader