0

I have two npz file, downloaded from Biobank :

The first file is chr6_24000001_27000001.gz and the second is chr6_25000001_28000001.gz.

Based on previous suggestion here and here , I reazlied that my files containng five arrays and tried to concotenate them.

But for the third array which it name is 'format', I got error message :

Traceback (most recent call last): File "", line 1, in File "<array_function internals>", line 180, in concatenate ValueError: zero-dimensional arrays cannot be concatenated

By runnung this code : data2['format'] the answer is array(b'coo', dtype='|S3')

I`m not very familiar with Python but after a lot of searching, the only place that I found S3 type was here.

I used this code to combine two npz files:

data1 = np.load('chr6_24000001_27000001.npz' , allow_pickle=True) data2 = np.load('chr6_25000001_28000001.npz', allow_pickle=True)

for k in data1.files : ... print(k) ... row col format shape data

row = np.concatenate([data1['row'], data2['row']]) col = np.concatenate([data1['col'], data2['col']])

data2['format'] array(b'coo', dtype='|S3') data1['format'] array(b'coo', dtype='|S3')

print(data1['format']) b'coo' print(data2['format']) b'coo'

format = data1['format']

Because two content where the same and I don`t know what was inside them!

shape = np.concatenate([data1['shape'], data2['shape']]) data = np.concatenate([data1['data'], data2['data']])

np.savez_compressed('chr6_24000001_28000001.npz', row=row, col=col, format=format, shape=shape, data=data ) loaded = np.load('chr6_24000001_28000001.npz') print(np.array_equal(format , loaded['format'])) True

When I used this npz file, I got error :

ValueError: too many values to unpack (expected 2)

I`m so grteful if someone help me to combine these two files, correctly.

0 Answers0