【发布时间】:2014-05-26 20:23:20
【问题描述】:
我正在尝试水平合并两个 csv 文件。
我使用了这个命令:
paste -d ',' file1.csv file2.csv> results.csv
但它在第二行显示了与第二个 csv 输出的合并。像这样:
"Shares of Apple, Inc. near ex-dividend as it gears up to distribute $2.7 ...",Apple Inc. (AAPL),"May 8, 2014"
,0.125,0.0,pos
应该是这样的:
"Shares of Apple, Inc. near ex-dividend as it gears up to distribute $2.7 ...",Apple Inc. (AAPL),"May 8, 2014",0.125,0.0,pos
file1.csv
"Shares of Apple, Inc. near ex-dividend as it gears up to distribute $2.7 ...",Apple Inc. (AAPL),"May 8, 2014"
Apple Woos Dr. Dre With $3.2 Billion Offer for Beats to Fend Off Spotify as ...,Apple Inc. (AAPL),"May 8, 2014"
file2.csv
0.125,0.0,pos
0.0,0.75,neg
如何解决这个问题?
【问题讨论】:
-
能否请您发布文件的第一行?
-
您的输入文件可能有 CRLF,因为它在这里运行良好。
-
@alvits:合并的文件在行之间包含空格。