HFileCSV
jhplot.io

Class HFileCSV



  • public class HFileCSVextends Object
    Write or read data in CSV (comma-separated values) format. The CSV is data interchange Format (.csv) used to import/export spreadsheets between spreadsheet programs. The files are simple text files that can be readable. Should be used to write main ScaVis data structures and import them to spreadsheet (such as OpenOffice). You can write only one object in one file.
    • Constructor Summary

      Constructors 
      Constructor and Description
      HFileCSV(String file)
      Open file for reading assuming comma for value separation.
      HFileCSV(String file, String option)
      Open file for reading/writing.
      HFileCSV(String file, String option, char delim)
      Open a file to write/read data to/from a CSV file.
    • Method Summary

      Methods 
      Modifier and TypeMethod and Description
      booleanclose()
      Close the file if needed.
      voiddoc()
      Show online documentation.
      chargetQuotechar()
      Get current quote character.
      CSVReaderread()
      Read data as sheet.
      voidsetQuotechar(char c)
      Set a quote character.
      booleanwrite(double[] p)
      Write double 1D array into the CSV file.
      booleanwrite(H1D p)
      Write 1-D histograms (including errors) into the CSV file.
      booleanwrite(int[] p)
      Write double 1D array into the CSV file.
      booleanwrite(P0D p)
      Write 1D array into the CSV file.
      booleanwrite(P0I p)
      Write 1D array into the CSV file.
      booleanwrite(P1D p)
      Write 2D array into the CSV file.
      booleanwrite(PND p)
      Write N-dimensional array into CSV file.
      booleanwrite(PNI p)
      Write N-dimensional (integer) array into CSV file.
      booleanwrite(String[] p)
      Write double 1D array into the CSV file.
    • Constructor Detail

      • HFileCSV

        public HFileCSV(String file,        String option,        char delim)
        Open a file to write/read data to/from a CSV file. If "w" option is set, the old file will be removed. Use close() to flash the buffer and close the file. We suppress all quoting. The default value separation is comma.

        If the file name starts from http or ftp, we assume it is located on the Web and will attempt to read it from URL.

        Parameters:
        file - File name. Can be located on URL if starts from http or ftp.
        option - Option to create the file. If "w" - write a file (or read) file, if "r" only read created file.
        delim - separator of values. Default is "comma".
      • HFileCSV

        public HFileCSV(String file)
        Open file for reading assuming comma for value separation.
        Parameters:
        file - File name
      • HFileCSV

        public HFileCSV(String file,        String option)
        Open file for reading/writing. Assumes comma to separate the values. Now quotes by default.
        Parameters:
        file - File name
        option - option = "w" to write file, "r" to read file.
    • Method Detail

      • setQuotechar

        public void setQuotechar(char c)
        Set a quote character. By default, none.
        Parameters:
        c -
      • getQuotechar

        public char getQuotechar()
        Get current quote character.
        Returns:
        c
      • write

        public boolean write(double[] p)
        Write double 1D array into the CSV file.
        Parameters:
        p - input array
        Returns:
        true if success
      • write

        public boolean write(int[] p)
        Write double 1D array into the CSV file.
        Parameters:
        p - input array
        Returns:
        true if success
      • write

        public boolean write(String[] p)
        Write double 1D array into the CSV file.
        Parameters:
        p - input array
        Returns:
        true if success
      • write

        public boolean write(P0I p)
        Write 1D array into the CSV file.
        Parameters:
        p - input array
        Returns:
        true if success
      • write

        public boolean write(P0D p)
        Write 1D array into the CSV file.
        Parameters:
        p - input array
        Returns:
        true if success
      • write

        public boolean write(PND p)
        Write N-dimensional array into CSV file.
        Parameters:
        p - multidimensional array
        Returns:
        true if success
      • write

        public boolean write(PNI p)
        Write N-dimensional (integer) array into CSV file.
        Parameters:
        p - multidimensional array
        Returns:
        true if success
      • write

        public boolean write(H1D p)
        Write 1-D histograms (including errors) into the CSV file. First 2 columns are lower and upper edges of the bins, 3rd column is height, 4th is the error on the heights.
        Parameters:
        p - histogram
        Returns:
        true if success
      • write

        public boolean write(P1D p)
        Write 2D array into the CSV file.
        Parameters:
        p - input array
        Returns:
        true if success
      • read

        public CSVReader read()
        Read data as sheet.
        Returns:
        CSV file
      • close

        public boolean close()
        Close the file if needed.
        Returns:
        true if success
      • doc

        public void doc()
        Show online documentation.

SCaVis 1.7 © jWork.org