I'm a beginner in Java and a geomatics student.
I am using IntelliJ to export data from an XTF image that contains various information such as coordinates, timestamp etc...
This is my code:
FileWriter writer = new FileWriter( "DonneesPings1.csv" );
FileWriter writer2 = new FileWriter( "DonneesPings2.csv" );
writer.write( "X,Y\n" );
int limit = 0;
for (XtfPing ping : xtf.getPings())
{
if ( limit < 10000 )
{
writer.write( Double.toString( ping.x ) );
writer.write( "," );
writer.write( Double.toString( ping.y ) );
writer.write( "\n" );
}
else {
writer2.write( Double.toString( ping.x ) );
writer2.write( "," );
writer2.write( Double.toString( ping.y ) );
writer2.write( "\n" );
}
limit++;
}
writer.close();
The snippet above creates two .csv files ("DonneesPings1.csv" and "DonneesPings2") but its format is not good. Data are only put in one column with a comma as the separator.
Example:
Column A
X,Y
0.000000000,-00.00000000
0.022222222,-02.00000000
I would like the x coordinates to be in one column and the y coordinates in another.
Example:
Column A Column B
X Y
0.000000000 -00.00000000
0.022222222 -02.00000000
I can make it in Excel, but I would like to do it programmatically with IntelliJ.