import org.apache.commons.csv.*;
public class CSVProcessor {
public static void main(String[] args) {
try {
CSVParser parser = CSVParser.parse("data.csv", Charset.forName("UTF-8"), CSVFormat.DEFAULT);
for (CSVRecord record : parser) {
String name = record.get(0);
int age = Integer.parseInt(record.get(1));
System.out.println("Name: " + name + ", Age: " + age);
}
CSVPrinter printer = new CSVPrinter(new FileWriter("output.csv"), CSVFormat.DEFAULT);
printer.printRecord("John Doe", 25);
printer.printRecord("Jane Smith", 30);
printer.flush();
printer.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}