(Univocity Parsers framework usage examples) import com.univocity.parsers.csv.CsvParser; import com.univocity.parsers.csv.CsvParserSettings; import java.io.FileReader; import java.util.List; public class CSVParserExample { public static void main(String[] args) throws Exception { CsvParserSettings settings = new CsvParserSettings(); CsvParser parser = new CsvParser(settings); FileReader reader = new FileReader("sales_data.csv"); List<String[]> rows = parser.parseAll(reader); for (String[] row : rows) { String productName = row[0]; double price = Double.parseDouble(row[1]); String category = row[2]; // ... System.out.println("Product: " + productName + ", Price: " + price + ", Category: " + category); } reader.close(); } }


上一篇:
下一篇:
切换中文