我想加入或你可以说在其他输出.csv文件中联合两个csv文件, 例如假设我有一个带字段的csv文件 A,B,C,d,电子 另一个有字段a,b,c,x,y,z 我需要输出文件中的输出 - a,b,c,d,e,x,y,z
我做了但没有获得所需的输出,请让我知道工作java代码
int n1 = 3,n2 = 3;//stores the serial number of the column that has the duplicate data
BufferedReader br1=new BufferedReader(new InputStreamReader(new FileInputStream("c:/test/report1.csv")));
BufferedReader br2=new BufferedReader(new InputStreamReader(new FileInputStream("c:/test/report2.csv")));
String line1,line2;
while((line1=br1.readLine())!=null && (line2=br2.readLine())!=null){
String line=line1+","+line2;
String newL="";
StringTokenizer st=new StringTokenizer(line,",");
System.out.println("total tokens "+st.countTokens());
int i = 3;
for(int i=1;i<=st.countTokens();i++){
if((i==n1)||(i==n1+n2))
continue;
else
newL=newL+","+st.nextToken();
}
String l=newL.substring(1);
System.out.println("merged "+l);
//write this line to the output file
}