public class OtpsCsvOutput extends Object
csv = otp.createCSVOutput() csv.setHeader( [ 'lat', 'lon', 'total' ] ) csv.addRow( [ 45.123, 5.789, 42 ] ) csv.addRow( [ 45.124, 5.792, 34 ] ) csv.save('mydata.csv')TODO Rename this class to "TabularOutput" and allow for saving in various format.
Modifier | Constructor and Description |
---|---|
protected |
OtpsCsvOutput() |
Modifier and Type | Method and Description |
---|---|
void |
addRow(Object[] row)
Add a new row to the data.
|
String |
asText() |
void |
save(String file)
Save the data to a file.
|
void |
setHeader(Object[] headers)
Set the (optional) column header names.
|
public void setHeader(Object[] headers)
headers
- An array of string, each entry is the name of the corresponding column header,
in order.public void addRow(Object[] row)
row
- An array of objects. The order and size of the array should correspond to the
header. The default toString method of each object will be called to get the actual
data to output; so any type of object can be provided (string, numbers...)public void save(String file) throws IOException
file
- The name of the file to save the data to.IOException
- In case something bad happens (IO exception)public String asText() throws IOException
IOException
OtpsEntryPoint.setRetval()
Copyright © 2018. All rights reserved.