Frage

I have a CSV file which has several values and special characters. I have this "¡°" special character as well. How to ignore it while reading or writing to file? I have used the KettleCSVreader to read the file data.

public Map<String,List<String>> readCSV (Map<String, String> field, String delimiter,String fileLocation,String enclosure) {

 csvDataReader =new CsvDataReader(fileLocation, headerPresent, delimiter,enclosure!=null?enclosure:"\"" , rowLimit);

 csvvalue = csvDataReader.loadData();

 List<String> headers=new ArrayList<String>();
 List<String> selectedClomnVals=new ArrayList<String>(); 
 Map<String,List<String>> fieldValues = new LinkedHashMap<String, List<String>>();
 headers=csvDataReader.getHeader();
 for (String nm : field.keySet()) {
        String key = nm;
        String value = field.get(nm).toString().trim();
        int index=headers.indexOf(value);

        selectedClomnVals=csvDataReader.getColumnData(index);
        fieldValues.put(key, selectedClomnVals);    
    }

  return fieldValues;

}

While reading that particular special character i get an exception. Is there any way that i could ignore that character while reading or writing it to the file.

War es hilfreich?

Lösung

Look at the code of CsvDataReader, it uses an InputStreamReader to read the input, without specifying the Charset. In this case the InputStreamReader uses the default charset.
Either write an extension to the Kettle code, modify the Kettle code and contribute to the community or change your default charset.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top