public void cmdStatsWriteCsv(CommandSender sender) {
		List<String> activeDates = plugin.sqlDb.readActiveDates();
		int nPlayers = 0;
		List<LoginEntry> logins = new ArrayList<LoginEntry>();
		int nLogins = 0;
		int totalTimeOnline;
		int totalBlocksPlaced;
		int totalBlocksBroken;
		int nDates = 0;
		File saveFile = new File(plugin.getDataFolder(), "server.csv");
		BufferedWriter writer = null;
		
		// In case the savefile doesn't exist, create it
		if (!saveFile.exists()) {
			try {
				saveFile.createNewFile();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		try {
			writer = new BufferedWriter(new FileWriter(saveFile));
			writer.write("Date" + plugin.csvSeparator
					   + " Players" + plugin.csvSeparator
					   + " Logins" + plugin.csvSeparator
					   + " Tot Online Time" + plugin.csvSeparator
					   + " Blocks placed" + plugin.csvSeparator
					   + " Blocks broken\n");
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		for (String date : activeDates) {
			nDates++;
			nPlayers = plugin.sqlDb.readPlayersDate(date).size();
			logins = plugin.sqlDb.readLoginsDate(date);
			nLogins  = logins.size();
			totalTimeOnline = 0;
			totalBlocksPlaced = 0;
			totalBlocksBroken = 0;
			for (LoginEntry e : logins) {
				totalTimeOnline += e.getTimeOnline();
				totalBlocksPlaced += e.getBlocksPlaced();
				totalBlocksBroken += e.getBlocksBroken();
			}
			try {
				writer.write(date + plugin.csvSeparator + " "
						   + nPlayers + plugin.csvSeparator + " "
						   + nLogins + plugin.csvSeparator + " "
						   + totalTimeOnline + plugin.csvSeparator + " "
						   + totalBlocksPlaced + plugin.csvSeparator + " "
						   + totalBlocksBroken + "\n");
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		try {
			writer.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		sender.sendMessage("[Statistics] Server data for " + nDates + " days saved to server.csv");
	}