I feel like its probably a simple solution but I can’t seem to figure it out and my google-fu is failing me.
currently, I’m consuming data from a CSV file, I then read each line and append to a list. I then use join to combine them all but the output is separated by brackets. What am I missing here?
Code:
data_file = csv.reader(open(‘data.csv’,’r’))
ip_addr=[]
for row in data_file:
ip_addr.append(row)
combine_ips = ‘,’.join(map(str, ip_addr))
Output
[‘1.1.1.1’],[‘1.1.1.2’],[‘1.1.1.3’]
What I need: ( I need it to be a string of course)
1.1.1.1.1,1.1.1.2,1.1.1.3
ip_addr.append(row[0])
?row
is a list of all the fields in the CSV, soip_addr()
is a list of lists.str
output of a list uses brackets that way. You want to use formatting