Modifier and Type | Method and Description |
---|---|
static ContextSerializerCsv |
getInstance()
Return the singleton instance of this class.
|
void |
read(Context context,
BufferedReader file)
Read a context from a csv file.
|
static void |
register()
Register this class for reading .csv files.
|
void |
write(Context context,
BufferedWriter file)
Write a context to a csv file.
|
public static ContextSerializerCsv getInstance()
Return the singleton instance of this class.
public static void register()
Register this class for reading .csv files.
public void read(Context context, BufferedReader file) throws IOException
Read a context from a csv file.
The following format is respected:
The first line contains the attribute names, the other lines contains the observations identifier followed by boolean values
"",a,b,c,d,e
1,1,0,1,0,0
2,1,1,0,0,0
3,0,1,0,1,1
4,0,0,1,0,1
If the first attribute is the empty string, the first column corresponds to the individual identifiers. In the other case, the individual identifiers will be generated by successive integers.
a,b,c,d,e
1,0,1,0,0
1,1,0,0,0
0,1,0,1,1
0,0,1,0,1
read
in interface Reader<Context>
context
- a context to readfile
- a fileIOException
- When an IOException occurspublic void write(Context context, BufferedWriter file) throws IOException
Write a context to a csv file.
The following format is respected:
The first line contains the attribute names, the other lines contains the observations identifier followed by boolean values
"",a,b,c,d,e
1,1,0,1,0,0
2,1,1,0,0,0
3,0,1,0,1,1
4,0,0,1,0,1
write
in interface Writer<Context>
context
- a context to writefile
- a fileIOException
- When an IOException occursCopyright © 2010–2016 The Galactic Organization. All rights reserved.