我正在生成一个包含预期结果的csv,所有数字都是正确的。
但是,从表达的角度来看,它包含所有内容的括号和逗号等。
有没有办法删除这些内容?
我尝试添加逗号作为分隔符,但这并不能解决问题。
示例输出:
确定:('Egg',)
results = []
results1 = []
results2 = []
results3 = []
results4 = []
results5 = []
results6 = []
cur.execute(dbQuery)
results.extend(cur.fetchall())
cur.execute(dbQuery1)
results1.extend(cur.fetchall())
cur.execute(dbQuery2)
results2.extend(cur.fetchall())
cur.execute(dbQuery3)
results3.extend(cur.fetchall())
cur.execute(dbQuery4)
results4.extend(cur.fetchall())
cur.execute(dbQuery5)
results5.extend(cur.fetchall())
cur.execute(dbQuery6)
results6.extend(cur.fetchall())
with open("Stats.csv","wb") as csv_file:
csv_writer = csv.writer(csv_file)
csv_writer.writerow(['Query1','Query2','Query3','Query4','Query5','Query6','Query7'])
csv_writer.writerows(zip(*[results,results1,results2,results3,results4,results5,results6]))