i have a csv object that i loop through, each row with in the csv reader object is a list - what's the best way to convert that row object to a string?

i have a csv object that i loop through, each row with in the csv reader object is a list - what's the best way to convert that row object to a string?

I basically have something like this:
 
for m_row in msft_data:
m_symbol = 'MSFT'
m_row.insert(0,m_symbol)
line = str(m_row)
print(type(line))
print(line)

i have a csv object that i loop through, each row with in the csv reader object is a list - what's the best way to convert that row object to a string?

I basically have something like this:

```for m_row in msft_data:
    m_symbol = 'MSFT'
    m_row.insert(0,m_symbol)
    line = str(m_row)
    print(type(line))
    print(line)```

output:
 
<class 'str'>
['MSFT', '2019-01-31 11:40:00', '103.9300', '104.1900', '103.9150', '104.1700', '444704']

Guess I"m not sure why it's still contained within [ ] brackets like a list?
You already invited:

Ali

Upvotes from: Benny

It's because you're asking for the string form of a list object. If you just want the values as a comma-separated string, you'd use something like `','.join(str(x) for x in m_row)`.

Or even `','.join(m_row)` since it looks like your numbers are strings to start with.

If you wanna answer this question please Login or Register