Java Code Examples for au.com.bytecode.opencsv.CSVReader#readAll()

The following examples show how to use au.com.bytecode.opencsv.CSVReader#readAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CsvUtils.java    From pxf with Apache License 2.0 6 votes vote down vote up
/**
 * Get Table of data from CSV file
 *
 * @param pathToCsvFile to read from to Table
 * @return {@link Table} with data list from CSV file
 * @throws IOException
 */
public static Table getTable(String pathToCsvFile) throws IOException {

	// direct CSVReader to csv file
	CSVReader csvReader = new CSVReader(new FileReader(pathToCsvFile));

	// read csv file to List
	List<String[]> list = csvReader.readAll();

	// create table and load csv as list to it
	Table dataTable = new Table(pathToCsvFile, null);

	try {
		for (Iterator<String[]> iterator = list.iterator(); iterator.hasNext();) {
			dataTable.addRow(iterator.next());
		}
	} finally {
		csvReader.close();
	}

	return dataTable;
}
 
Example 2
Source File: OpenCSVParserExample.java    From journaldev with MIT License 6 votes vote down vote up
private static void parseCSVFileAsList() throws IOException {
	//create CSVReader object
	CSVReader reader = new CSVReader(new FileReader("employees.csv"), ',');

	List<Employee> emps = new ArrayList<Employee>();
	//read all lines at once
	List<String[]> records = reader.readAll();
	
	Iterator<String[]> iterator = records.iterator();
	//skip header row
	iterator.next();
	
	while(iterator.hasNext()){
		String[] record = iterator.next();
		Employee emp = new Employee();
		emp.setId(record[0]);
		emp.setName(record[1]);
		emp.setRole(record[2]);
		emp.setSalary(record[3]);
		emps.add(emp);
	}
	
	reader.close();
	
	System.out.println(emps);
}
 
Example 3
Source File: ReportDataLoader.java    From adwords-alerting with Apache License 2.0 6 votes vote down vote up
/**
 * Generate ReportData from an input stream (normally an HTTP steam of report in CSV format),
 * which will be closed after reading.
 * @param stream the input stream (in CSV format)
 * @param clientCustomerId the client customer ID of this report
 * @return the generated ReportData
 */
public ReportData fromStream(InputStream stream, Long clientCustomerId) throws IOException {
  CSVReader csvReader = new CSVReader(new InputStreamReader(stream, Charset.defaultCharset()));
  String[] headerArray = csvReader.readNext();
  List<String[]> rowsArray = csvReader.readAll();
  csvReader.close();

  int rowsCount = rowsArray.size();
  List<List<String>> rows = new ArrayList<List<String>>(rowsCount);
  for (int i = 0; i < rowsCount; ++i) {
    // need to create a new ArrayList object which is extendible.
    List<String> row = new ArrayList<String>(Arrays.asList(rowsArray.get(i)));
    rows.add(row);
  }

  int columns = headerArray.length;
  List<String> columnNames = new ArrayList<String>(columns);
  for (int i = 0; i < columns; i++) {
    String fieldName = fieldsMapping.get(headerArray[i]);
    Preconditions.checkNotNull(fieldName, "Unknown field name: %s.", fieldName);
    columnNames.add(fieldName);
  }

  return new ReportData(clientCustomerId, reportType, columnNames, rows);
}
 
Example 4
Source File: YahooQuoteMessageConverter.java    From cloudstreetmarket.com with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected QuoteWrapper readInternal(Class<? extends QuoteWrapper> clazz, HttpInputMessage httpInputMessage) throws IOException, HttpMessageNotReadableException {
    CSVReader reader = new CSVReader(new InputStreamReader(httpInputMessage.getBody()));
    List<String[]> rows = reader.readAll();
    QuoteWrapper quoteWrapper = new QuoteWrapper();
    for (String[] row : rows) {
    	quoteWrapper.add(new YahooQuote(row[0], 
    								row[1], 
    								parseDouble(row[2]), 
    								parseDouble(row[3]), 
    								parseDouble(row[4]), 
    								parseDouble(row[5]), 
    								parsePercent(row[6]), 
    								parseDouble(row[7]), 
    								parseDouble(row[8]), 
    								parseDouble(row[9]), 
    								parseDouble(row[10]), 
    								parseInt(row[11]), 
    								row[12], 
    								row[13]));
    }

    return quoteWrapper;
}
 
Example 5
Source File: YahooHistoMessageConverter.java    From cloudstreetmarket.com with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected QuoteWrapper readInternal(Class<? extends QuoteWrapper> clazz, HttpInputMessage httpInputMessage) throws IOException, HttpMessageNotReadableException {
    CSVReader reader = new CSVReader(new InputStreamReader(httpInputMessage.getBody()));
    List<String[]> rows = reader.readAll();
    QuoteWrapper quoteWrapper = new QuoteWrapper();
    for (String[] row : rows) {

    	quoteWrapper.add(new YahooQuote(row[0], 
    								row[1], 
    								parseDouble(row[2]), 
    								parseDouble(row[3]), 
    								parseDouble(row[4]), 
    								parseDouble(row[5]), 
    								parsePercent(row[6]), 
    								parseDouble(row[7]), 
    								parseDouble(row[8]), 
    								parseDouble(row[9]), 
    								parseDouble(row[10]), 
    								parseInt(row[11]), 
    								row[12], 
    								row[13]));
    }

    return quoteWrapper;
}
 
Example 6
Source File: MySpreadsheetIntegration.java    From AIDR with GNU Affero General Public License v3.0 6 votes vote down vote up
public static void main(String[] args)
        throws Exception{

    String[] row = null;

    URL stockURL = new URL("http://localhost:8888/tornadotweets.csv");
    BufferedReader in = new BufferedReader(new InputStreamReader(stockURL.openStream()));

    CSVReader csvReader = new CSVReader(in);
    List content = csvReader.readAll();

    for (Object object : content) {
        row = (String[]) object;

        System.out.println(row[0]
                + " # " + row[1]
                + " #  " + row[2]);
    }
    csvReader.close();
}
 
Example 7
Source File: CVSRemoteFileFormatter.java    From AIDR with GNU Affero General Public License v3.0 5 votes vote down vote up
public List<MicromapperInput> getGeoClickerInputData(String url) throws Exception{
    //"tweetID","tweet","author","lat","lng","url","created","answer"
    String[] row = null;
    List<MicromapperInput> sourceSet = new ArrayList<MicromapperInput>();

    CSVReader csvReader = getCVSContentReader(url) ;
    List content = csvReader.readAll();

    for (Object object : content) {
        row = (String[]) object;
        if(row!=null){
            if(row.length > 7){
                String tweetID = row[0];
                String tweet=row[1];
                String author=row[2];
                String lat=row[3];
                String lng=row[4];
                String imgURL = row[5];
                String created = row[6];
                String answer = row[7];

                MicromapperInput source = new MicromapperInput(tweetID, tweet, author, lat, lng, imgURL, created, answer);
                sourceSet.add(source);
            }
        }
    }
    csvReader.close();

    if(sourceSet.size() > 1){
        sourceSet.remove(0);
    }

    return sourceSet;
}
 
Example 8
Source File: CVSRemoteFileFormatter.java    From AIDR with GNU Affero General Public License v3.0 5 votes vote down vote up
public List<MicromapperInput> getInputData(String url) throws Exception{
    //[Twitter username] // [Tweet message] // [optional: time-stamp] // [optional: location] // [optional: latitude] // [optional: longitude] // [image link]


    String[] row = null;
    List<MicromapperInput> sourceSet = new ArrayList<MicromapperInput>();

    URL stockURL = new URL(url);
    BufferedReader in = new BufferedReader(new InputStreamReader(stockURL.openStream()));

    CSVReader csvReader = new CSVReader(in);
    List content = csvReader.readAll();

    for (Object object : content) {
        row = (String[]) object;

       //  tweetID,tweet,author,lat,lng,url,created
        MicromapperInput source = new MicromapperInput(row[0], row[1], row[2], row[3], row[4], row[5], row[6]);
        sourceSet.add(source);
    }
    csvReader.close();

    if(sourceSet.size() > 1){
        sourceSet.remove(0);
    }

    return sourceSet;
}
 
Example 9
Source File: TeamCity.java    From at.info-knowledge-base with MIT License 5 votes vote down vote up
public Result getResultsFromCSV(String filePath) {
    Result results = new Result();
    try {
        CSVReader reader = new CSVReader(new FileReader(new File(filePath)));
        List<String[]> lines = reader.readAll();
        for (String[] test : lines.subList(1, lines.size())) {
            results.addResult(test[1], test[2]);
        }
    } catch (Exception e) {/**/}
    return results;
}
 
Example 10
Source File: CsvServiceImpl.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public List<String[]> buildLinesFromFile(File file) throws IOException {
  CSVReader reader =
      createCsvReader(file.getName(), removeByteOrderMark(new FileInputStream(file)));
  List<String[]> content = reader.readAll();
  validateCsvFile(content, file.getName());
  return content;
}
 
Example 11
Source File: TravelDocumentServiceImpl.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 *
 */
@Override
public List<GroupTraveler> importGroupTravelers(final TravelDocument document, final String csvData) throws Exception {
    final List<GroupTraveler> retval = new LinkedList<GroupTraveler>();
    final BufferedReader bufferedFileReader = new BufferedReader(new StringReader(csvData));
    final CSVReader csvReader = new CSVReader(bufferedFileReader);

    final List<String[]> rows;
    try {
        rows = csvReader.readAll();
    }
    catch (IOException ex) {
        ex.printStackTrace();
        throw new ParseException("Could not  parse CSV file data", ex);
    }
    finally {
        try {
            csvReader.close();
        }
        catch (Exception e) {}
    }

    final Map<String,List<Integer>> header = getGroupTravelerHeaders();

    for (final String[] row : rows) {
        final GroupTravelerCsvRecord record = createGroupTravelerCsvRecord(header, row);
        final GroupTraveler traveler = new GroupTraveler();
        traveler.setGroupTravelerEmpId(record.getGroupTravelerEmpId());
        traveler.setName(record.getName());
        traveler.setGroupTravelerType(record.getGroupTravelerType());
        retval.add(traveler);
    }

    return retval;
}
 
Example 12
Source File: LogicParser.java    From barchomat with GNU General Public License v2.0 5 votes vote down vote up
static ArrayList<Logic.Data> loadLogicFile(InputStream in) throws IOException {
    CSVReader reader = new CSVReader(new InputStreamReader(in));
    List<String[]> lines = reader.readAll();
    String[] header = lines.get(0);
    Logic.Data.Type[] types = parseTypes(lines.get(1));
    if (!NAME_KEY.equals(header[0]) || types[0] != Logic.Data.Type.STRING) {
        log.debug("Forcing Name column");
        header[0] = NAME_KEY;
        types[0] = Logic.Data.Type.STRING;
    }

    ArrayList<Logic.Data> logic = new ArrayList<>();

    Logic.Data data = null;
    for (int i = 2; i < lines.size(); i++) {
        String[] line = lines.get(i);
        if (!isNullOrEmpty(line[0])) {
            data = new Logic.Data(header);
            logic.add(data);
        } else if (data == null) {
            throw new ResourceException("Sub-header not found");
        }
        data.addLine(parseValues(types, line));
    }

    return logic;
}
 
Example 13
Source File: YahooIntraDayHistoMessageConverter.java    From cloudstreetmarket.com with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected QuoteWrapper readInternal(Class<? extends QuoteWrapper> clazz, HttpInputMessage httpInputMessage) throws IOException, HttpMessageNotReadableException {
    CSVReader reader = new CSVReader(new InputStreamReader(httpInputMessage.getBody()));
    List<String[]> rows = reader.readAll();
    QuoteWrapper quoteWrapper = new QuoteWrapper();
    for (String[] row : rows) {
    	
    	try{
    		Integer.valueOf(row[0]);
    	}
    	catch(NumberFormatException e){
    		break;
    	}

    	quoteWrapper.add(new YahooQuote(row[0], 
    								row[1], 
    								parseDouble(row[2]), 
    								parseDouble(row[3]), 
    								parseDouble(row[4]), 
    								parseDouble(row[5]), 
    								parsePercent(row[6]), 
    								parseDouble(row[7]), 
    								parseDouble(row[8]), 
    								parseDouble(row[9]), 
    								parseDouble(row[10]), 
    								parseInt(row[11]), 
    								row[12], 
    								row[13]));
    }

    return quoteWrapper;
}
 
Example 14
Source File: CVSRemoteFileFormatter.java    From AIDR with GNU Affero General Public License v3.0 4 votes vote down vote up
public List<MicromapperInput> getClickerLocalFileInputData(String csvFilename) throws Exception{
    //[Twitter username] // [Tweet message] // [optional: time-stamp] // [optional: location] // [optional: latitude] // [optional: longitude] // [image link]
    String[] row = null;
    List<MicromapperInput> sourceSet = new ArrayList<MicromapperInput>();

    CSVReader csvReader = getCVSContentReader(csvFilename) ;
    List content = csvReader.readAll();

    for (Object object : content) {
        //User-Name(0)	Tweet(1)	Time-stamp(2)	Location(3)	Latitude(4)	Longitude(5)	Image-link(6)	TweetID(7)
        // public MicromapperInput(String tweetID, String tweet, String author, String lat, String lng , String url, String created){
        row = (String[]) object;
        if(row!=null){
            if(row.length > 7){

                String tweetID = row[7];
                String tweet=row[1];
                String author=row[0];
                String lat=row[4];
                String lng=row[5];
                String imgURL = row[6];
                String created = row[2];
                String dataSourceLocation;

                MicromapperInput source = new MicromapperInput(tweetID, tweet, author, lat, lng, imgURL, created);
                sourceSet.add(source);
            }
        }
        //  tweetID,tweet,author,lat,lng,url,created



    }
    csvReader.close();
    // REMOVEW HEADER
    if(sourceSet.size() > 1){
        sourceSet.remove(0);
    }

    return sourceSet;
}
 
Example 15
Source File: CsvBatchInputFileTypeBase.java    From kfs with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * @see org.kuali.kfs.sys.batch.BatchInputFileType#parse(byte[])
 * 
 * @return parsed object in structure - List<Map<String, String>>
 */
public Object parse(byte[] fileByteContent) throws ParseException {
    
    // handle null objects and zero byte contents
    String errorMessage = fileByteContent == null? "an invalid(null) argument was given" : 
        fileByteContent.length == 0? "an invalid argument was given, empty input stream" : "";
    
    if (!errorMessage.isEmpty()){
        LOG.error(errorMessage);
        throw new IllegalArgumentException(errorMessage);
    }

    List<String> headerList = getCsvHeaderList();
    Object parsedContents = null;
    try {
        // validate csv header
        ByteArrayInputStream validateFileContents = new ByteArrayInputStream(fileByteContent);
        validateCSVFileInput(headerList, validateFileContents);
        
        //use csv reader to parse the csv content
        CSVReader csvReader = new CSVReader(new InputStreamReader(new ByteArrayInputStream(fileByteContent)));
        List<String[]>dataList = csvReader.readAll();
        
        //remove first header line
        dataList.remove(0);
        
        //parse and create List of Maps base on enum value names as map keys
        List<Map<String, String>> dataMapList = new ArrayList<Map<String, String>>();
        Map<String, String>rowMap;
        int index = 0;
        for (String[] row : dataList){
            rowMap = new LinkedHashMap<String, String>();
            // reset index
            index = 0;
            
            for (String header : headerList){
                rowMap.put(header, row[index++]);
            }
            dataMapList.add(rowMap);
        }
        
        parsedContents = dataMapList;
    }catch (IOException ex) {
        LOG.error(ex.getMessage(), ex);
        throw new ParseException(ex.getMessage(), ex);
    }
    return parsedContents;    
}
 
Example 16
Source File: CfdaServiceImpl.java    From kfs with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * @return
 * @throws IOException
 */
public SortedMap<String, CFDA> getGovCodes() throws IOException {
    Calendar calendar = dateTimeService.getCurrentCalendar();
    SortedMap<String, CFDA> govMap = new TreeMap<String, CFDA>();

    // ftp://ftp.cfda.gov/programs09187.csv
    String govURL = parameterService.getParameterValueAsString(CfdaBatchStep.class, KFSConstants.SOURCE_URL_PARAMETER);
    String fileName = StringUtils.substringAfterLast(govURL, "/");
    govURL = StringUtils.substringBeforeLast(govURL, "/");
    if (StringUtils.contains(govURL, "ftp://")) {
        govURL = StringUtils.remove(govURL, "ftp://");
    }

    // need to pull off the '20' in 2009
    String year = "" + calendar.get(Calendar.YEAR);
    year = year.substring(2, 4);
    fileName = fileName + year;

    // the last 3 numbers in the file name are the day of the year, but the files are from "yesterday"
    fileName = fileName + String.format("%03d", calendar.get(Calendar.DAY_OF_YEAR) - 1);
    fileName = fileName + ".csv";

    LOG.info("Getting government file: " + fileName + " for update");

    InputStream inputStream = null;
    FTPClient ftp = new FTPClient();
    try {
        ftp.connect(govURL);
        int reply = ftp.getReplyCode();

        if (!FTPReply.isPositiveCompletion(reply)) {
            LOG.error("FTP connection to server not established.");
            throw new IOException("FTP connection to server not established.");
        }

        boolean isLoggedIn = ftp.login("anonymous", "");
        if (!isLoggedIn) {
            LOG.error("Could not login as anonymous.");
            throw new IOException("Could not login as anonymous.");
        }

        LOG.info("Successfully connected and logged in");
        ftp.enterLocalPassiveMode();
        inputStream = ftp.retrieveFileStream(fileName);
        if (inputStream != null) {
            LOG.info("reading input stream");
            InputStreamReader screenReader = new InputStreamReader(inputStream);
            BufferedReader screen = new BufferedReader(screenReader);

            CSVReader csvReader = new CSVReader(screenReader, ',', '"', 1);
            List<String[]> lines = csvReader.readAll();
            for (String[] line : lines) {
                String title = line[0];
                String number = line[1];

                CFDA cfda = new CFDA();
                cfda.setCfdaNumber(number);
                cfda.setCfdaProgramTitleName(title);

                govMap.put(number, cfda);
            }
        }

        ftp.logout();
        ftp.disconnect();
    }
    finally {
        if (ftp.isConnected()) {
            ftp.disconnect();
        }
    }

    return govMap;
}
 
Example 17
Source File: ImportExportTask.java    From Passbook with Apache License 2.0 4 votes vote down vote up
private String importPbCSV() {
    String result;
    try {
        CSVReader csvReader = new CSVReader(new FileReader(mFilePath));
        List<String[]> content = csvReader.readAll();
        csvReader.close();
        AccountManager appAm = Application.getInstance().getAccountManager();
        Hashtable<String, Integer> existingCategory = new Hashtable<>();
        Hashtable<String, Integer> existingAccounts = new Hashtable<>();
        List<AccountManager.Category> categories = appAm.getCategoryList(true, false);
        for(AccountManager.Category c : categories) {
            existingCategory.put(c.mName, c.mId);
        }
        for(String s : content.get(0)) {
            if(existingCategory.get(s) == null) {
                existingCategory.put(s, appAm.addCategory(0, s));
            }
        }
        String[] line;
        String names[];
        String fields[];
        AccountManager.Account account;
        Integer accId;
        int categoryId;
        if(mOption != OPTION_KEEPALL) {
            List<AccountManager.Account> accounts = appAm.getAllAccounts(false);
            for(AccountManager.Account a : accounts) {
                existingAccounts.put(a.mProfile, a.mId);
            }
            for(int i = 1; i < content.size(); ++i) {
                line = content.get(i);
                names = line[0].split("\t", 2);
                accId = existingAccounts.get(names[1]);
                if(accId != null && mOption == OPTION_IGNORE) {
                    continue;
                }
                categoryId = existingCategory.get(names[0]);
                if(accId == null) {
                    account = appAm.newAccount(categoryId);
                }
                else {
                    account = appAm.getAccountById(accId);
                    account.setCategory(categoryId);
                }
                account.setName(names[1]);
                account.clearEntries();
                for(int j = 1; j < line.length; ++j) {
                    fields = line[j].split("\t", 3);
                    account.addEntry(Integer.parseInt(fields[0]), fields[1], fields[2]);
                }
                if(accId == null) {
                    appAm.addAccount(categoryId, account);
                }
                else {
                    appAm.setAccount(account);
                }
            }
        }
        else {
            for(int i = 1; i < content.size(); ++i) {
                line = content.get(i);
                names = line[0].split("\t", 2);
                categoryId = existingCategory.get(names[0]);
                account = appAm.newAccount(categoryId);
                account.setName(names[1]);
                for(int j = 1; j < line.length; ++j) {
                    fields = line[j].split("\t", 3);
                    account.addEntry(Integer.parseInt(fields[0]), fields[1], fields[2]);
                }
                appAm.addAccount(categoryId, account);
            }
        }
        result = mFilePath;

    } catch (Exception e) {
        result = null;
    }
    return result;
}
 
Example 18
Source File: StatCounterConfigManager.java    From mts with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Returns a list of counters depending on the requested level
 * 
 * @param level
 */
public synchronized List<CounterReportTemplate> getTemplateList(StatKey level) throws Exception
{
    String key = getTemplateFilename(level);
    
    // search in the template map list
    List<CounterReportTemplate> templateList = templateMapList.get(key);
    if (templateList != null)
    {
        return templateList;
    }
    templateMapList.put(key, templateList);
    
    String fileName = FORMATTER_DIR + key + ".csv";
    CSVReader csvReader = new CSVReader(new InputStreamReader(SingletonFSInterface.instance().getInputStream(new URI(fileName))), CSV_SEPARATOR.charAt(0));
    List<String[]> list = csvReader.readAll();

    templateList = new LinkedList<CounterReportTemplate>();
    int index = 0;

    for (String[] line : list)
    {
        if (index > 0)
        {
            String type = line[0];
            StatKey arg1 = new StatKey(Utils.splitNoRegex(line[1].substring(1),"/"));

            StatKey arg2 = null;
            if (line[2].length() > 0)
            {
                arg2 = new StatKey(Utils.splitNoRegex(line[2].substring(1),"/"));
            }

            String descrShort = line[3];
            String description = line[4];                
            String descrLong = line[5];
            CounterReportTemplate template = new CounterReportTemplate(type, arg1, arg2, descrShort, description, descrLong);
            templateList.add(template);
        }
        index++;
    }

    return templateList;
}
 
Example 19
Source File: CVSRemoteFileFormatter.java    From AIDR with GNU Affero General Public License v3.0 4 votes vote down vote up
public List<MicromapperInput> getClickerInputData(String url) throws Exception{
     //[Twitter username] // [Tweet message] // [optional: time-stamp] // [optional: location] // [optional: latitude] // [optional: longitude] // [image link]
    String[] row = null;
    List<MicromapperInput> sourceSet = new ArrayList<MicromapperInput>();

    CSVReader csvReader = getCVSContentReader(url) ;
    List content = csvReader.readAll();

    for (Object object : content) {
        //User-Name(0)	Tweet(1)	Time-stamp(2)	Location(3)	Latitude(4)	Longitude(5)	Image-link(6)	TweetID(7)
       // public MicromapperInput(String tweetID, String tweet, String author, String lat, String lng , String url, String created){
        row = (String[]) object;
        if(row!=null){
            if(row.length > 7){

                String tweetID = row[7];
                String tweet=row[1];
                String author=row[0];
                String lat=row[4];
                String lng=row[5];
                String imgURL = row[6];
                String created = row[2];
                String dataSourceLocation;

                MicromapperInput source = new MicromapperInput(tweetID, tweet, author, lat, lng, imgURL, created);
                sourceSet.add(source);
            }
        }
        //  tweetID,tweet,author,lat,lng,url,created



    }
    csvReader.close();
    // REMOVEW HEADER
    if(sourceSet.size() > 1){
        sourceSet.remove(0);
    }

    return sourceSet;
}
 
Example 20
Source File: ContainerUtils.java    From sofa-acts with Apache License 2.0 4 votes vote down vote up
/**
 *
 * @param clsChild
 * @param cvsChild
 * @param csvParent
 * @throws FileNotFoundException
 * @throws IOException
 */
private static void csvReplaceObj(Class<?> clsChild, String cvsChild, String csvParent,
                                  Set<String> sbfWarn) {
    try {
        if (null != clsChild) {
            FileReader fReader = new FileReader(csvParent);
            CSVReader csvReader = new CSVReader(fReader);
            List<String[]> readLine = csvReader.readAll();
            List<String> addLine = new ArrayList<String>(6);
            int i = 0;
            for (String[] readDetail : readLine) {
                if (StringUtils.equals(readDetail[2], "java.lang.Object")) {
                    addLine.add(readDetail[0]);
                    addLine.add(readDetail[1]);
                    addLine.add(clsChild.getName());
                    addLine.add(readDetail[3]);

                    if (CSVApisUtil.isWrapClass(clsChild)) {
                        if (StringUtils.equals(clsChild.getName(), "java.lang.String")) {
                            addLine.add("Y");
                            addLine.add("1");
                        } else {
                            CSVApisUtil.addSimpleValue("", clsChild, addLine);
                        }
                    } else if (StringUtils.isNotBlank(cvsChild)) {
                        File openFile = new File(cvsChild);
                        if (openFile.exists()) {
                            addLine.add("Y");
                            addLine.add(CSVApisUtil.cutCsvName(cvsChild) + "@1");
                        } else {
                            addLine.add("N");
                            addLine.add("");
                        }
                    } else {
                        addLine.add("N");
                        addLine.add("");
                    }
                    break;
                }
                i++;
            }

            readLine.set(i, addLine.toArray(new String[addLine.size()]));

            csvReader.close();
            fReader.close();

            FileWriter fWrite = new FileWriter(csvParent);
            CSVWriter csvWriter = new CSVWriter(fWrite);
            csvWriter.writeAll(readLine);
            csvWriter.close();
            fWrite.close();
        }
    } catch (Exception e) {
        sbfWarn.add("failed to add sub-file [" + CSVApisUtil.cutCsvName(cvsChild)
                    + "] to file [" + CSVApisUtil.cutCsvName(csvParent) + "]");
    }
}