【发布时间】:2020-01-20 15:51:01
【问题描述】:
如何将此 csv 文件转换为制表符分隔文件?
"Country","Percent","Percent of patients","home health","home health agency","friends and family","Surveys","Response"
"Nation","88","85","83","84","78",,
请注意,Surverys 和 Response 列都是空字符串。
我使用此代码将其转换为选项卡文件 -
sed 's/\"\,\"/\"\t\"/g'
sed 's/\,\,/\t""\t/g'
但它不会转换最后一列。这是我得到的输出(注意最后一列被省略了) -
"Country" "Percent" "Percent of patients" "home health" "home health agency" "friends and family" "Surveys" "Response"
"Nation" "88" "85" "83" "84" "78" ""
表头有 8 列,制表符分隔的数据只有 7 列,所以漏掉了最后一列。
更新
我的列名中有逗号。
【问题讨论】: