jhplot.io
Class HFileCSV
- java.lang.Object
-
- jhplot.io.HFileCSV
-
public class HFileCSV extends java.lang.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 DMelt 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(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 Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description boolean
close()
Close the file if needed.void
doc()
Show online documentation.char
getQuotechar()
Get current quote character.CSVReader
read()
Read data as sheet.void
setQuotechar(char c)
Set a quote character.boolean
write(double[] p)
Write double 1D array into the CSV file.boolean
write(H1D p)
Write 1-D histograms (including errors) into the CSV file.boolean
write(int[] p)
Write double 1D array into the CSV file.boolean
write(P0D p)
Write 1D array into the CSV file.boolean
write(P0I p)
Write 1D array into the CSV file.boolean
write(P1D p)
Write 2D array into the CSV file.boolean
write(PND p)
Write N-dimensional array into CSV file.boolean
write(PNI p)
Write N-dimensional (integer) array into CSV file.boolean
write(java.lang.String[] p)
Write double 1D array into the CSV file.
-
-
-
Constructor Detail
-
HFileCSV
public 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".
-
HFileCSV
public HFileCSV(java.lang.String file)
Open file for reading assuming comma for value separation.- Parameters:
file
- File name
-
HFileCSV
public 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 nameoption
- 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(java.lang.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.
-
-
DMelt 3.0 © DataMelt by jWork.ORG