import os
import numpy as np
# import subprocess

def test():
    file_pth = '/project_pth/command_cr.txt'
    save_pth = '/project_pth/command_cr_cut.txt'

    with open(file_pth,'r') as f:
        a = 0
        with open(save_pth,'w') as w:
            for line in f.readlines():
                file_name = line.split(' ')[-1].replace('\n','')

                subset_name = [file for file in os.listdir(file_name) if '.csv' in file][0]
                print(subset_name)
                voxel_pth = os.path.join(file_name, f"{subset_name}"+'_voxel_crop.npy')
                
                if not(os.path.exists(voxel_pth)):
                    w.writelines(line)
                    print(voxel_pth,'None!')
                else:
                    a+=1
                    print(voxel_pth)
                    # data = np.load(voxel_pth)  
                    # print(data.shape)
    print(a)

def load_one():
    data_pth = ''
    data = np.load(data_pth)
    print(data.shape)

# test()
    
data_pth = '/data/user/DATASETS/CRSOT/train_subset'
for seq_name in sorted(os.listdir(data_pth)):
    seq_pth = os.path.join(data_pth,seq_name)
    data_ls = [file for file in os.listdir(seq_pth) if 'csv' not in file]
    # print(data_ls)
    if len(data_ls)>0:
        print(seq_pth)