package biblioteki.csv;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.nio.charset.Charset;

import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVParser;
import org.apache.commons.csv.CSVRecord;

public class Odczyt2 {

	public static void main(String[] args) {
		// gdyby trzeba było wskazać kodowanie znaków, np. windows
		
		CSVFormat format = CSVFormat.EXCEL.withDelimiter(';');
		try(Reader input = new BufferedReader(new FileReader("b.csv", Charset.forName("windows-1250")));
			CSVParser parser = new CSVParser(input, format)) {
			
			for(CSVRecord record : parser) {
				System.out.println(record);
				System.out.println("  imię:" + record.get(0));
				System.out.println("  nazwisko:" + record.get(1));
				System.out.println();
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
