valiantljk / h5spark

Supporting Hierarchical Data Format and Rich Parallel I/O Interface in Spark
Other
42 stars 25 forks source link

NameError: global name 'x' is not defined #15

Closed dnorvell closed 8 years ago

dnorvell commented 8 years ago

Hey guys, in your read.py file of the h5spark module I am getting a variable definition error if an exception is thrown.

I'm unsure what this variable is supposed to be or where its supposed to be defined. It could be possible I am somehow giving it bad input but just wanted to see if this was a known issue, or if something funky was going on.

#read a slice from one dataset/file
def readonep(filename, dset_name, i1, chunk_size):
        try:
                f=h5py.File(filename,'r')
                d = f[dset_name]
                if i1 + chunk_size < d.shape[0]:
                        chunk = d[i1:i1+chunk_size,:]
                else:
                        chunk = d[i1:d.shape[0],:]
                return list(chunk[:])
        except Exception, e:
                print "ioerror:%s"%e, x[0]  # <-- Error thrown here
        finally:
                pass
                f.close()

Thanks for any feedback, Drew

valiantljk commented 8 years ago

Hi Drew, Thanks for pointing out, I replaced the x[0] to filename, should be working now.

Best, Jialin