public static function get_structured_data(\stored_file $dataset) {

        if ($dataset->get_filearea() !== 'unlabelled') {
            throw new \coding_exception('Sorry, only support for unlabelled data');
        }

        $rh = $dataset->get_content_file_handle();

        // Skip dataset info.
        fgets($rh);
        fgets($rh);

        $calculations = array();

        $headers = fgetcsv($rh);
        // Get rid of the sampleid column name.
        array_shift($headers);

        while ($columns = fgetcsv($rh)) {
            $uniquesampleid = array_shift($columns);

            // Unfortunately fgetcsv does not respect line's var types.
            $calculations[$uniquesampleid] = array_map(function($value) {

                if ($value === '') {
                    // We really want them as null because converted to float become 0
                    // and we need to treat the values separately.
                    return null;
                } else if (is_numeric($value)) {
                    return floatval($value);
                }
                return $value;
            }, array_combine($headers, $columns));
        }

        return $calculations;
    }
public static function get_structured_data(\stored_file $dataset) {

        if ($dataset->get_filearea() !== 'unlabelled') {
            throw new \coding_exception('Sorry, only support for unlabelled data');
        }

        $rh = $dataset->get_content_file_handle();

        // Skip dataset info.
        fgets($rh);
        fgets($rh);

        $calculations = array();

        $headers = fgetcsv($rh);
        // Get rid of the sampleid column name.
        array_shift($headers);

        while ($columns = fgetcsv($rh)) {
            $uniquesampleid = array_shift($columns);

            // Unfortunately fgetcsv does not respect line's var types.
            $calculations[$uniquesampleid] = array_map(function($value) {

                if ($value === '') {
                    // We really want them as null because converted to float become 0
                    // and we need to treat the values separately.
                    return null;
                } else if (is_numeric($value)) {
                    return floatval($value);
                }
                return $value;
            }, array_combine($headers, $columns));
        }

        return $calculations;
    }
public static function get_structured_data ( \ stored_file $ dataset ) { if ( $ dataset -> get_filearea ( ) !== 'unlabelled' ) { throw new \ coding_exception ( 'Sorry, only support for unlabelled data' ) ; } $ rh = $ dataset -> get_content_file_handle ( ) ; // Skip dataset info. fgets ( $ rh ) ; fgets ( $ rh ) ; $ calculations = array ( ) ; $ headers = fgetcsv ( $ rh ) ; // Get rid of the sampleid column name. array_shift ( $ headers ) ; while ( $ columns = fgetcsv ( $ rh ) ) { $ uniquesampleid = array_shift ( $ columns ) ; // Unfortunately fgetcsv does not respect line's var types. $ calculations [ $ uniquesampleid ] = array_map ( function ( $ value ) { if ( $ value === '' ) { // We really want them as null because converted to float become 0 // and we need to treat the values separately. return null ; } else if ( is_numeric ( $ value ) ) { return floatval ( $ value ) ; } return $ value ; } , array_combine ( $ headers , $ columns ) ) ; } return $ calculations ; }
Returns the dataset file data structured by sampleids using the indicators and target column names.

@param \stored_file $dataset
@return array
Returns the dataset file data structured by sampleids using the indicators and target column names .