read function

Generic read method to read data from a file or a folder.