我已經獲得了包含電子商務平臺產品信息的CSV文件。 CSV文件包含具有相同產品ID和多個說明的多行。每個值由「^」而不是逗號分隔。 我想要實現的是將這些多行合併爲一個逗號分隔,並且只有一行產品信息。所以我的問題是組合多個具有相同屬性的行。具有相同ID的CSV文件多行代碼
這是今天
productID^Element^Value<br>
id01^Status^01<br>
id01^edited^2016-01-01<br>
id01^Longdesc^Here goes the description<br>
id01^Longdesc^Here is the second line of description<br>
id01^longdesc^And the third row<br>
id01^image^Link to image 1<br>
文件的格式化這就是我要找的實現:
ID01, 2016-01-01, Here goes the description Here is the second line of description And the third row, link to image
另一個想法是把結構的很好的XML文件。
希望你們有這方面的一些很好的解決方案,可以幫助我。
謝謝!
這似乎是一個很簡單的問題 - 遍歷線,解析它們,並重新打印出來你最喜歡的方式。你到目前爲止嘗試了什麼? –
我試過這個:http://stackoverflow.com/questions/25610886/how-to-concatenate-values-from-multiple-rows-with-the-same-id-to-a-comma-separat但是不能得到長話結合。 – Koolander