1

I have a csv like below :

jobid,userid,scheduleTime,start_date,end_date,job_frequency,day,status,fileserver,reportid
1,1,15:37:00,2016-05-12,2016-05-15,0,MON-FRI,scheduled,xy,1

I want to parse this csv read it and if status fileds value is scheduled , it needs to be updated to completed .

I am able to parse it :

public void UpdateScheduleInfo(String metaFile){

        System.out.println("Enterring UpdateScheduleInfo method::");
        List<CreateScheduleDao> ScheduleList = new ArrayList<CreateScheduleDao>();

        CSVFormat csvFileFormat = CSVFormat.EXCEL.withHeader();

        FileReader file = null;
        CSVParser csvParser = null;


        try {
            file= new FileReader(metaFile);
            csvParser = new CSVParser(file,csvFileFormat);  
            List<CSVRecord> records = csvParser.getRecords();
            /
            for (int i = 0; i < records.size(); i++) {

                if (records.get(i).get(7).equals("scheduled")){
                    System.out.println("Changing the status");

Please suggest how to update it

riteshtch
  • 8,629
  • 4
  • 25
  • 38
  • 2
    Possible duplicate of [updating specific cell csv file using java](http://stackoverflow.com/questions/4397907/updating-specific-cell-csv-file-using-java) – Ani Menon May 16 '16 at 06:03
  • I think you cannot change the data you are currently reading. Just write the data record by record after reading. At that time you can change the record as you like, ie. change `scheduled` to `fixed`. After that drop the original file and rename the newly written to that name. – chris May 16 '16 at 06:45

0 Answers0