Untitled
unknown
python
2 years ago
997 B
4
Indexable
Never
MP_numbers=['001','002','004','0072'] list_of_files=[ 'xxx_mp-000.csv', 'yyy_mp-000.csv', 'aaa_mp-003.csv', 'bbb_mp-004.csv', 'ccc_mp-001.csv', 'ddd_mp-0076.csv', 'd_mp-004.csv', 'e_mp-003.csv', 'f_mp-004.csv', 'g_mp-002.csv', 'h_mp-007.csv', 'i_mp-0076.csv', 'j_mp-004.csv', 'k_mp-001.csv', 'l_mp-000.csv', 'm_mp-004.csv', 'n_mp-009.csv', 'o_mp-008.csv', 'p_mp-009.csv', 'q_mp-001.csv', 'r_mp-004.csv', 'zzz_mp-001.csv', ] idx=list() for i in list_of_files: # Tady se vyrezava cislo souboru a misto "-" muzes zacit laborovat # s jinou funkci a parametrem napr. "MP-" apod. key = i.split('-')[1].split('.')[0] idx.append((key,i)) MP_output=dict() for i in MP_numbers: MP_output[i] = list() for key,val in idx: if key in MP_numbers: MP_output[key].append(val) print(MP_output)