:read(nbytes)Reads to a buffer then turns into a lua string.Allocates memory on each call, so slightly inefficient if you do manyreads.Doesn't allocate memory, just casts using ffi.Calls fwrite and returns its ret val, i.e. Constructor: file = GZFile(filename, mode)Opens the file for reading or writing using the given mode.See zlib gzopen() documentation for supported modes.To access the underlying FILE* handle, use the handle property of GZFile. Note: compressing floats can be useful for neural nets, since similar values atsimilar orders of magnitude will often results in repeated byte patterns. Read 200 floats from a gzipped file directly into a torch tensor: Implemented as an FFI wrapper for zlib, including wrappers for C FILEfunctions like fscanf and fwrite. This is NOT a problem, but it does affect how you might write fscanf code to read this text string.Ĭonveniently (and with decent performance) read and write data from gzipfiles directly. Thus, even though you look at the file as individual lines, fscanf sees it as: setting1 = 1 setting2 = 2 setting3 = 3. The first thing you should know is that fscanf treats new line characters as white space. First of all there is nothing wrong with fscanf.