我有一个类似下面的 CSV
Element,Value
LIN,887873083091
QTY,12
LIN,887873083107
QTY,13
LIN,887873083114
QTY,10
LIN,887873083121
QTY,6
LIN,887873083138
QTY,0
Avialability,018
Avail_Date,20391231
LIN,887873083145
QTY,0
Avialability,018
Avail_Date,20391231
LIN,886732553461
QTY,0
Avialability,018
Avail_Date,20391231
LIN,886732637901
QTY,0
Avialability,018
Avail_Date,20391231
LIN,886732637918
QTY,0
Avialability,018
Avail_Date,20391231
LIN,886732637925
QTY,0
Avialability,018
Avail_Date,20391231
LIN,886732637932
QTY,0
Avialability,018
Avail_Date,20391231
LIN,886732637949
QTY,0
Avialability,018
Avail_Date,20391231
LIN,886732637956
QTY,0
Avialability,018
Avail_Date,20391231
LIN,886732637963
QTY,0
Avialability,018
Avail_Date,20391231
LIN,886732637970
QTY,0
Avialability,018
Avail_Date,20391231
如您所见,有 4 个元素。LIN,数量,可用性,Avail_Date
我想将这些元素作为列并在其下放置值并将其作为 CSV 文件。
像下面的示例
LIN,QTY,Availability,Avail_Date
887873083091,12,,
887873083107,13,,
887873083114,10,,
887873083121,6,,
887873083138,0,018,20391231
887873083145,0,018,20391231
886732553461,0,018,20391231
原来的顺序是 LIN、QTY、Availability 和 Avail_Date .. 但在某些情况下,Availability 和 Avail_Date 可能会丢失。在这种情况下,我想将空白放入新的 CSV,就像示例输出中的前 4 行一样。
我怎样才能为此编写Java代码?谁能给出任何解决方案?我什么都没试过,因为我不知道