public void writeFinalResults ( ) { printStatus ( ) ; try ( PrintStream out = new PrintStream ( ExampleHelpers . openExampleFileOuputStream ( "gender-ratios.csv" ) ) ) { out . print ( "Site key,pages total,pages on humans,pages on humans with gender" ) ; for ( EntityIdValue gender : this . genderNamesList ) { out . print ( "," + this . genderNames . get ( gender ) + " (" + gender . getId ( ) + ")" ) ; } out . println ( ) ; List < SiteRecord > siteRecords = new ArrayList <> ( this . siteRecords . values ( ) ) ; Collections . sort ( siteRecords , new SiteRecordComparator ( ) ) ; for ( SiteRecord siteRecord : siteRecords ) { out . print ( siteRecord . siteKey + "," + siteRecord . pageCount + "," + siteRecord . humanPageCount + "," + siteRecord . humanGenderPageCount ) ; for ( EntityIdValue gender : this . genderNamesList ) { if ( siteRecord . genderCounts . containsKey ( gender ) ) { out . print ( "," + siteRecord . genderCounts . get ( gender ) ) ; } else { out . print ( ",0" ) ; } } out . println ( ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } }
Writes the results of the processing to a CSV file .