Skip to content

Commit 7064c42

Browse files
author
Rajeev Kumar Singh
committed
Capital Header Names
1 parent 94b1e08 commit 7064c42

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

java-csv-file-handling-with-apache-commons-csv/src/main/java/CSVReaderWithHeaderAutoDetection.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ public static void main(String[] args) throws IOException {
2727
for (CSVRecord csvRecord : csvRecords) {
2828
// Accessing values by Header names
2929

30-
String name = csvRecord.get("name");
31-
String email = csvRecord.get("email");
32-
String phone = csvRecord.get("phone");
33-
String country = csvRecord.get("country");
30+
String name = csvRecord.get("Name");
31+
String email = csvRecord.get("Email");
32+
String phone = csvRecord.get("Phone");
33+
String country = csvRecord.get("Country");
3434

3535
System.out.println("Record No - " + csvRecord.getRecordNumber());
3636
System.out.println("---------------");

java-csv-file-handling-with-apache-commons-csv/src/main/java/CSVReaderWithManualHeader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static void main(String[] args) throws IOException {
1818
try (
1919
Reader reader = Files.newBufferedReader(Paths.get(SAMPLE_CSV_FILE_PATH));
2020
CSVParser csvParser = new CSVParser(reader, CSVFormat.DEFAULT
21-
.withHeader("name", "email", "phone", "country")
21+
.withHeader("Name", "Email", "Phone", "Country")
2222
.withIgnoreHeaderCase()
2323
.withTrim());
2424
) {
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
Rajeev Kumar Singh ♥,rajeevs@example.com,+91-9999999999,India
2-
32
Sachin Tendulkar,sachin@example.com,+91-9999999998,India
43
Barak Obama,barak.obama@example.com,+1-1111111111,United States
54
Donald Trump,donald.trump@example.com,+1-2222222222,United States

0 commit comments

Comments
 (0)