All Downloads are FREE. Search and download functionalities are using the official Maven repository.

weka.core.converters.CSVSaver Maven / Gradle / Ivy

Go to download

The Waikato Environment for Knowledge Analysis (WEKA), a machine learning workbench. This is the stable version. Apart from bugfixes, this version does not receive any other updates.

There is a newer version: 3.8.6
Show newest version
/*
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see .
 */

/*
 *    CSVSaver.java
 *    Copyright (C) 2004-2012 University of Waikato, Hamilton, New Zealand
 *
 */

package weka.core.converters;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Vector;

import weka.core.AbstractInstance;
import weka.core.Capabilities;
import weka.core.Capabilities.Capability;
import weka.core.DenseInstance;
import weka.core.Instance;
import weka.core.Instances;
import weka.core.Option;
import weka.core.RevisionUtils;
import weka.core.SparseInstance;
import weka.core.Utils;

/**
 *  Writes to a destination that is in CSV
 * (comma-separated values) format. The column separator can be chosen (default
 * is ',') as well as the value representing missing values (default is '?').
 * 

* * * Valid options are: *

* *

 * -F <separator>
 *  The field separator to be used.
 *  '\t' can be used as well.
 *  (default: ',')
 * 
* *
 * -M <str>
 *  The string representing a missing value.
 *  (default: ?)
 * 
* *
 * -N
 *  Don't write a header row.
 * 
* *
 * -decimal <num>
 *  The maximum number of digits to print after the decimal
 *  place for numeric values (default: 6)
 * 
* *
 * -i <the input file>
 *  The input file
 * 
* *
 * -o <the output file>
 *  The output file
 * 
* * * * @author Stefan Mutter ([email protected]) * @version $Revision: 10203 $ * @see Saver */ public class CSVSaver extends AbstractFileSaver implements BatchConverter, IncrementalConverter, FileSourcedConverter { /** for serialization. */ static final long serialVersionUID = 476636654410701807L; /** the field separator. */ protected String m_FieldSeparator = ","; /** The placeholder for missing values. */ protected String m_MissingValue = "?"; /** Max number of decimal places for numeric values */ protected int m_MaxDecimalPlaces = AbstractInstance.s_numericAfterDecimalPoint; /** Set to true to not write the header row */ protected boolean m_noHeaderRow = false; /** * Constructor. */ public CSVSaver() { resetOptions(); } /** * Returns a string describing this Saver. * * @return a description of the Saver suitable for displaying in the * explorer/experimenter gui */ public String globalInfo() { return "Writes to a destination that is in CSV (comma-separated values) format. " + "The column separator can be chosen (default is ',') as well as the value " + "representing missing values (default is '?')."; } /** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options. */ @Override public Enumeration




© 2015 - 2024 Weber Informatics LLC | Privacy Policy