function main() {
	var fields;
	var data;
	var opts;
	var json;
	var tmp;
	var d;
	var i;
	var j;

	opts = {
		'encoding': 'utf8'
	};

	// Read the raw CSV file:
	data = readFile( INPUT_CSV, opts );
	if ( data instanceof Error ) {
		throw data;
	}

	// Parse the CSV data (NOTE: we assume well-formatted CSV)...
	data = data.split( RE_EOL );
	fields = data[ 0 ].split( ',' );
	data = data.slice( 1, data.length-1 ); // remove the header line and trailing newline
	for ( i = 0; i < data.length; i++ ) {
		d = data[ i ].split( ',' );
		if ( d.length !== fields.length ) {
			throw new Error( 'unexpected error. Number of row values ('+d.length+') does not match the expected number of fields ('+fields.length+').' );
		}
		for ( j = 0; j < d.length; j++ ) {
			d[ j ] = parseFloat( d[ j ] );
		}
		data[ i ] = d;
	}

	// Create the JSON data...
	json = [];
	for ( i = 0; i < data.length; i++ ) {
		d = data[ i ];
		tmp = {};
		for ( j = 0; j < fields.length; j++ ) {
			tmp[ fields[ j ] ] = d[ j ];
		}
		json.push( tmp );
	}

	// Write the output file:
	writeFile( OUTPUT_JSON, JSON.stringify( json )+'\n', opts );
}
Main execution sequence.

@private
@throws {Error} unexpected error