Low-resolution spectroscopy of gamma-ray burst optical afterglows: biases in the swift sample and characterization of the absorbers