From 946241dca5b59d1cee60b66818c9651c4d831164 Mon Sep 17 00:00:00 2001 From: PrasadKarunagoda Date: Fri, 17 Sep 2021 00:09:03 +0530 Subject: [PATCH] Use setLinesToSkip to skip the header line of the CSV file --- .../java/io/javabrains/ipldashboard/data/BatchConfig.java | 8 ++++++-- src/main/resources/match-data.csv | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/javabrains/ipldashboard/data/BatchConfig.java b/src/main/java/io/javabrains/ipldashboard/data/BatchConfig.java index bb64c68..02635ab 100644 --- a/src/main/java/io/javabrains/ipldashboard/data/BatchConfig.java +++ b/src/main/java/io/javabrains/ipldashboard/data/BatchConfig.java @@ -37,13 +37,17 @@ public class BatchConfig { @Bean public FlatFileItemReader reader() { - return new FlatFileItemReaderBuilder().name("MatchItemReader") + FlatFileItemReader flatFileItemReader = new FlatFileItemReaderBuilder() + .name("MatchItemReader") .resource(new ClassPathResource("match-data.csv")).delimited().names(FIELD_NAMES) .fieldSetMapper(new BeanWrapperFieldSetMapper() { { setTargetType(MatchInput.class); } }).build(); + + flatFileItemReader.setLinesToSkip(1); + return flatFileItemReader; } @Bean @@ -81,4 +85,4 @@ public Step step1(JdbcBatchItemWriter writer) { .writer(writer) .build(); } -} \ No newline at end of file +} diff --git a/src/main/resources/match-data.csv b/src/main/resources/match-data.csv index 30230ed..b62c70c 100644 --- a/src/main/resources/match-data.csv +++ b/src/main/resources/match-data.csv @@ -1,3 +1,4 @@ +id,city,date,player_of_match,venue,neutral_venue,team1,team2,toss_winner,toss_decision,winner,result,result_margin,eliminator,method,umpire1,umpire2 335982,Bangalore,2008-04-18,BB McCullum,M Chinnaswamy Stadium,0,Royal Challengers Bangalore,Kolkata Knight Riders,Royal Challengers Bangalore,field,Kolkata Knight Riders,runs,140,N,NA,Asad Rauf,RE Koertzen 335983,Chandigarh,2008-04-19,MEK Hussey,"Punjab Cricket Association Stadium, Mohali",0,Kings XI Punjab,Chennai Super Kings,Chennai Super Kings,bat,Chennai Super Kings,runs,33,N,NA,MR Benson,SL Shastri 335984,Delhi,2008-04-19,MF Maharoof,Feroz Shah Kotla,0,Delhi Capitals,Rajasthan Royals,Rajasthan Royals,bat,Delhi Capitals,wickets,9,N,NA,Aleem Dar,GA Pratapkumar @@ -813,4 +814,4 @@ 1237177,Dubai,2020-11-05,JJ Bumrah,Dubai International Cricket Stadium,0,Mumbai Indians,Delhi Capitals,Delhi Capitals,field,Mumbai Indians,runs,57,N,NA,CB Gaffaney,Nitin Menon 1237178,Abu Dhabi,2020-11-06,KS Williamson,Sheikh Zayed Stadium,0,Royal Challengers Bangalore,Sunrisers Hyderabad,Sunrisers Hyderabad,field,Sunrisers Hyderabad,wickets,6,N,NA,PR Reiffel,S Ravi 1237180,Abu Dhabi,2020-11-08,MP Stoinis,Sheikh Zayed Stadium,0,Delhi Capitals,Sunrisers Hyderabad,Delhi Capitals,bat,Delhi Capitals,runs,17,N,NA,PR Reiffel,S Ravi -1237181,Dubai,2020-11-10,TA Boult,Dubai International Cricket Stadium,0,Delhi Capitals,Mumbai Indians,Delhi Capitals,bat,Mumbai Indians,wickets,5,N,NA,CB Gaffaney,Nitin Menon \ No newline at end of file +1237181,Dubai,2020-11-10,TA Boult,Dubai International Cricket Stadium,0,Delhi Capitals,Mumbai Indians,Delhi Capitals,bat,Mumbai Indians,wickets,5,N,NA,CB Gaffaney,Nitin Menon