我正在尝试将数据写入 csv 文件,我创建了四列作为val csvFields = Array("Serial Number", "Record Type", First File value", Second file value") ', 除了序列号,其他三个字段都是列表Second_file_value = List ("B", "gjgbn", "fgbhjf", "dfjf")First_File_Value = List ("A","abhc","agch","mknk")Record_type = List('1','2',3','4'); val outputFile = new BufferedWriter(new FileWriter("Resulet.csv") val csvWriter = new CSVWriter(outputFile) val listOfRecords = new ListBuffer[Array[String]]() listOfRecords :+ csvFields我正在使用此循环写入列for ( i <- 1 until 30){listOfRecords += Array(i.toString, Record_type , First_File_Value , Second_file_value )}csvWriter.writeAll(listOfRecords.toList)output.close()我面临的问题是 csv 文件填充了 30 行相同的值(第一行值),列表中的值没有得到迭代。任何参考资料也将有所帮助
添加回答
举报
0/150
提交
取消