Python list write to CSV without the square brackets -


i have main function:

def main():     subprocess.call("cls", shell=true)     iplist,hostlist,manflist,masterlist,temp = [],[],[],[],[]     iplist,hostlist,manflist, = getips(),gethosts(),getmanfs()     entries = len(hostlist)     = 0     in xrange(i, entries):         temp = [[hostlist[i]],[manflist[i]],[iplist[i]]]         masterlist.append(temp)      open("output.csv", "wb") f:         writer = csv.writer(f, delimiter=',')         writer.writerows(masterlist) 

my current output writes csv objective remove square brackets.

i tried using .join() method understand takes single lists , not nested lists.

how can achieve given i'm using 3 dimensional list? note, intend add more columns of data in future.


edit:

my current output 1 row similar to:

['name1,'] ['brand,'] ['1.1.1.1,']

i be:

name1, brand, 1.1.1.1,

try remove bracket values in temp while creating masterlist, because nested list. so, code should be:

def main():     subprocess.call("cls", shell=true)     iplist,hostlist,manflist,masterlist,temp = [],[],[],[],[]     iplist,hostlist,manflist, = getips(),gethosts(),getmanfs()     entries = len(hostlist)     = 0     in xrange(i, entries):         temp = [hostlist[i], manflist[i], iplist[i]]         masterlist.append(temp)      open("output.csv", "wb") f:         writer = csv.writer(f, delimiter=',')         writer.writerows(masterlist) 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -