jhplot.io
Class HFileCSV
- java.lang.Object
- 
- jhplot.io.HFileCSV
 
- 
 
 public class HFileCSV extends java.lang.ObjectWrite 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 DMelt data structures and import them to spreadsheet (such as OpenOffice). You can write only one object in one file.
- 
- 
Constructor SummaryConstructors Constructor and Description HFileCSV(java.lang.String file)Open file for reading assuming comma for value separation.HFileCSV(java.lang.String file, java.lang.String option)Open file for reading/writing.HFileCSV(java.lang.String file, java.lang.String option, char delim)Open a file to write/read data to/from a CSV file.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method 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(java.lang.String[] p)Write double 1D array into the CSV file.
 
- 
- 
- 
Constructor Detail- 
HFileCSVpublic HFileCSV(java.lang.String file, java.lang.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".
 
 - 
HFileCSVpublic HFileCSV(java.lang.String file) Open file for reading assuming comma for value separation.- Parameters:
- file- File name
 
 - 
HFileCSVpublic HFileCSV(java.lang.String file, java.lang.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- 
setQuotecharpublic void setQuotechar(char c) Set a quote character. By default, none.- Parameters:
- c-
 
 - 
getQuotecharpublic char getQuotechar() Get current quote character.- Returns:
- c
 
 - 
writepublic boolean write(double[] p) Write double 1D array into the CSV file.- Parameters:
- p- input array
- Returns:
- true if success
 
 - 
writepublic boolean write(int[] p) Write double 1D array into the CSV file.- Parameters:
- p- input array
- Returns:
- true if success
 
 - 
writepublic boolean write(java.lang.String[] p) Write double 1D array into the CSV file.- Parameters:
- p- input array
- Returns:
- true if success
 
 - 
writepublic boolean write(P0I p) Write 1D array into the CSV file.- Parameters:
- p- input array
- Returns:
- true if success
 
 - 
writepublic boolean write(P0D p) Write 1D array into the CSV file.- Parameters:
- p- input array
- Returns:
- true if success
 
 - 
writepublic boolean write(PND p) Write N-dimensional array into CSV file.- Parameters:
- p- multidimensional array
- Returns:
- true if success
 
 - 
writepublic boolean write(PNI p) Write N-dimensional (integer) array into CSV file.- Parameters:
- p- multidimensional array
- Returns:
- true if success
 
 - 
writepublic 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
 
 - 
writepublic boolean write(P1D p) Write 2D array into the CSV file.- Parameters:
- p- input array
- Returns:
- true if success
 
 - 
readpublic CSVReader read() Read data as sheet.- Returns:
- CSV file
 
 - 
closepublic boolean close() Close the file if needed.- Returns:
- true if success
 
 - 
docpublic void doc() Show online documentation.
 
- 
 
- 
DMelt 3.0 © DataMelt by jWork.ORG