functions to sample file