I modified my code:
private static final String SAMPLE_CSV_FILE_PATH = "src/main/resources/testCSV.csv";
private static final String OUT_PUT_CSV_PATH = "src/main/resources/outCSV.csv";
public static void main(String[] args) throws IOException {
Reader reader = Files.newBufferedReader(Paths.get(SAMPLE_CSV_FILE_PATH));
CSVReader csvReader = new CSVReader(reader);
List<String[]> records = csvReader.readAll();
Writer writer = Files.newBufferedWriter(Paths.get(OUT_PUT_CSV_PATH));
CSVWriter out = new CSVWriter(writer);
int i = 1;
int total = 0;
while(i < records.size()){
String[] result = records.get(i);
for(int j =1; j<= Integer.parseInt(result[1]); j++){
String pattern="00000";
DecimalFormat myFormatter = new DecimalFormat(pattern);
String output = myFormatter.format(j);
writer.append(result[0]+output+"\n");
total++;
}
i++;
}
out.flush();
out.close();
System.out.println(total);
}
Now I am using the first CSV file to generate the serial number, Something like:
NAIS00001
NAIS00002
...
NAIS00625
Then I write these serial numbers into a new CSV file. But there is only one column. 6 millions data in one column... How can I star a new column?