开发者

python adding a title row to csv output file

开发者 https://www.devze.com 2023-03-25 11:35 出处:网络
I have a python script that gets data from a database and outputs a csv file. Now I\'m trying to add a header row containing titles for each of the columns. What do I need to add so that it outputs an

I have a python script that gets data from a database and outputs a csv file. Now I'm trying to add a header row containing titles for each of the columns. What do I need to add so that it outputs an initial row ahead of the db output (I'm qui开发者_开发技巧te a newbie to python, so I got stuck in this part and couldn't find the info I needed)?

Thanks in advance!


If you're using a DictWriter, you can just call writeheader.

0

精彩评论

暂无评论...
验证码 换一张
取 消