如何在CSV文件的字段中添加引号? [英] How can I add quotation marks to fields in a CSV file?
本文介绍了如何在CSV文件的字段中添加引号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个CSV文件,例如
I've got a CSV file like
Brand,Type,Color
Porsche,Sport,Red
BMW,Coupe,Blue
我想用引号引起来:
"Brand","Type","Color"
"Porsche","Sport","Red"
"BMW","Coupe","Blue"
最快的方法是什么?我将在cronjob中实现它.
What's the fastest way to do it? I will implement it in a cronjob.
推荐答案
使用sed:
sed -e 's/^\|$/"/g' -e 's/,/","/g' input
这篇关于如何在CSV文件的字段中添加引号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文