Convert a list of strings into individual string in Python -


a newbie question apologize if it's basic. have set, myset, filled reading csv file see below printed representation.

set(['value1', 'value2']) 

the number of elements on set arbitrary, depending upon read file. want add entries on csv file using individual elements of set. i've tried:

    file_row = ['#entry','time', str(myset), 'cpu usage']     print file_row     filewriter.writerow(file_row) 

however output is:

#entry,time,"set(['value1', 'value2'])",cpu usage 

where wanted

#entry,time,value1,value2,cpu usage. 

can suggest how desired result ?

you approach follows:

file_row = ['#entry','time'] # start pre-myset elements file_row.extend(myset) # add on myset file_row.append('cpu usage') # add final item 

note using set means order of elements arbitrary.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -