public static void main(String[] args) throws IOException, SQLException {

		if (args.length < 1) {
			System.out.println("Specify input file");
			return;
		}

		String fileName = args[0];
		System.out.println("Processing " + fileName);

		File inputFile = new File(fileName);
		List<String> inputLines = FileUtils.readLines(inputFile, "Unicode");

		if (inputLines.size() <= 0) {
			System.out.println("No data for processing");
			return;
		}

		System.out.println("Skipping header: " + inputLines.get(0));

		if (inputLines.size() == 1) {
			System.out.println("No data for processing");
			return;
		}

		List<Record> result = parseRecords(inputLines);

		// trying to save

		if (ToDatabase) {
			Connection connection = DriverManager.getConnection(
					"jdbc:postgresql://127.0.0.1:5432/rgeothes", "postgres",
					"postgres");

			connection.setAutoCommit(true);

			clearThesaurus(connection);

			new RecordDao(connection).addRecords(result);

		}

		if (ToXml) {

			XStream xstream = new XStream(new DomDriver());

			xstream.alias("record", Record.class);
			xstream.alias("name", Name.class);
			xstream.alias("document", Document.class);
			xstream.alias("recordReference", RecordReference.class);
			xstream.alias("location", Location.class);
			xstream.alias("point", Point.class);
			xstream.alias("rectangle", Rectangle.class);

			xstream.setMode(XStream.NO_REFERENCES);

			String serialized = xstream.toXML(result);

			File outputFile = new File("kz.xml");

			FileUtils.writeStringToFile(outputFile, serialized, "Unicode");

		}

	}