你好我想在終端中用awk在我的CSV文件中添加列標題。在終端中用AWK添加CSV格式的列標題
當前顯示:
Michael, [email protected], Seattle, Washington, detail1, detail2, detail3
所需的格式:
Name, Email, City, State, more1, more2, more3etc
Michael, [email protected], Seattle, Washington, detail1, detail2, detail3,
是否嘗試過這樣的事情,但我最終得到 「非法口供的源代碼行2」:
awk 'BEGIN {FS=",";OFS=","; print "Rating,Restaurant,Address,Landline,Mobile,Cuisine,Website,LatDD,LonDD"}
NR >1 {print ",",,,",",",", }' Restaurants.txt > Restaurants_newer.txt
這一問題是否會減少對 「插入我的文件的開頭行」? –
爲什麼所需格式的第一行與您試圖插入awk命令的格式不同? –
第二次打印有語法錯誤:太多','。 –