A deposition in a case at law, taken on such notice under the three preceding sections, may be read in such case, if when it is offered, the deponent be dead, or out of this state, or one of its judges, or in any public office or service the duties of which prevent his attending the court, or be unable to attend it from sickness or other infirmity, or be out of the county in which the case is pending, or, because of lapse of time or mental infirmity, be unable to remember any material part of what he had deposed to. But when the only ground of reading a deposition is that the deponent is out of the county, on motion to the court, before the commencement of the trial, the court may, for good cause shown, require such deponent to attend in person.