package org.datavec.api.transform.transform.parse;

import org.datavec.api.transform.ColumnType;
import org.datavec.api.transform.schema.Schema;
import org.datavec.api.transform.transform.BaseTransform;
import org.datavec.api.writable.DoubleWritable;
import org.datavec.api.writable.Text;
import org.datavec.api.writable.Writable;

import java.util.ArrayList;
import java.util.List;

/**
 *  Convert string writables to doubles
 *
 *  @author Adam GIbson
 */
public class ParseDoubleTransform extends BaseTransform {

    @Override
    public String toString() {
        return getClass().getName();
    }

    /**
     * Get the output schema for this transformation, given an input schema
     *
     * @param inputSchema
     */
    @Override
    public Schema transform(Schema inputSchema) {
       Schema.Builder newSchema = new Schema.Builder();
       for(int i = 0; i < inputSchema.numColumns(); i++) {
           if(inputSchema.getType(i) == ColumnType.String) {
               newSchema.addColumnDouble(inputSchema.getMetaData(i).getName());
           }
           else
               newSchema.addColumn(inputSchema.getMetaData(i));

       }
        return newSchema.build();
    }

    @Override
    public List<Writable> map(List<Writable> writables) {
        List<Writable> transform = new ArrayList<>();
        for(int i = 0; i < writables.size(); i++) {
            if(writables.get(i) instanceof Text) {
                transform.add(new DoubleWritable(Double.parseDouble(writables.get(i).toString())));
            }
        }
        return transform;
    }
}

@@ -1331,46 +1331,31 @@
 for(
-int i = 0; i %3C writables.size(); i++) 
+Writable w : writables)
 %7B%0A  
@@ -1368,31 +1368,16 @@
     if(w
-ritables.get(i)
  instanc
@@ -1385,17 +1385,16 @@
 of Text)
- 
 %7B%0A      
@@ -1440,56 +1440,76 @@
 ble(
+w.to
 Double
-.parseDouble(writables.get(i).toString()))
+()));%0A            %7D else %7B%0A                transform.add(w
 );%0A 

Fix ParseDoubleTransform