代码:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2020/11/23 22:49
# @Author : Qiufen.Chen
# @Email : [email protected]
# @File : count_file_line.py
# @Software: PyCharm
"""统计一个文件夹里总共有多少文件以及每一个文件里的行数"""
import os
file_dir = '/home/cqfnenu/LSTM/data/atom_data_new/'
file_num = 0
for (root, dirs, files) in os.walk(file_dir):
for file_name in files:
file_num += 1
with open(os.path.join(root, file_name), 'r') as f1:
line_num = 0
lines = f1.readlines()
for line in lines:
line_num += 1
print(str(file_name.split('.')[0]), line_num)
print('此文件夹共有 %s 个文件' %file_num)
结果:
ssh://cqfnenu@XXXXXXXXXX/usr/bin/python -u /home/cqfnenu/LSTM/pre_processing/count_file.py
4q2e_A 198
6adq_H 57
4w6v_A 273
2k9p_A 52
6rko_A 179
2n4x_A 94
2l35_A 47
6fmx_A 129
6rmg_A 217
2b6v_A 157
4rp8_A 185
1pb4_C 69
5j4i_A 221
5k7l_A 137
2kse_A 34
5v7p_A 134
2yiu_A 115
2bmn_A 163
3ukm_A 101
2axt_B 106
6n3q_A 157
6k1h_Z 71
4uvm_A 237
4ytp_C 68
6igz_G 33
6i1r_A 178
2ksf_A 76
4bpd_A 47
6gct_A 223
6pl5_A 146
3k3f_A 165
5xj5_A 110
6a90_A 410
6pv7_B 76
6kzo_A 399
4he8_C 149
3s0x_A 96
3j1z_P 93
6hug_B 85
6qkc_I 72
6hwh_b 46
4hyc_A 136
4uqq_B 41
6jbj_A 140
2mmu_A 44
5m87_A 220
4k0e_A 212
5nl2_A 166
6hum_D 220
5do7_A 117
5jrw_A 40
5zx5_A 101
2vpw_C 136
6tdx_O 26
6btm_F 168
6mhu_F 122
4jbw_F 152
2m67_A 43
6gdg_A 137
6mho_B 139
5tqq_A 236
5jnq_A 146
6ak3_B 171
6cfw_G 52
3k07_A 225
6ab9_A 162
6cdu_A 86
6c70_A 121
5fmw_A 26
6bw5_A 141
6p49_A 146
6hra_B 114
6f0k_C 197
5oge_A 196
6val_A 74
5vre_A 124
2yev_A 360
6b87_A 48
4xxj_A 121
6p25_A 183
6p6i_B 98
4aq5_C 94
6f36_N 34
6eyu_A 114
4c7r_A 181
5gar_O 28
6ffc_A 148
4ryi_A 101
5eke_A 49
5y78_A 180
5duo_A 114
6aei_A 94
5mdx_R 41
6pnj_L 44
6bms_A 101
3c1g_A 206
4rng_A 63
6rag_B 125
6ffv_A 123
5da0_A 198
4qtn_A 107
1fft_A 190
1rh5_A 180
4czb_A 232
6awf_D 82
6drk_A 118
6co7_A 89
6rv2_A 84
5kc0_A 107
3p5n_A 111
2a65_A 279
5mg3_Y 138
6r6b_F 40
3rgb_C 65
2d2c_A 70
4ytp_D 66
4umv_A 132
5iji_A 47
6gcs_2 229
5ndd_A 164
5i9k_A 96
6c3o_A 38
2lp1_A 27
5f1c_A 45
6adq_G 70
3iz1_A 108
6hu9_b 35
5uar_A 205
6c26_3 43
6caa_A 237
5eik_A 129
4bbj_A 171
4dji_A 285
5ezm_A 219
2xq2_A 237
5n6h_A 161
4o6m_A 100
4dbl_A 175
6ryo_A 82
4kpp_A 244
6i6h_A 151
6hum_A 144
6mrt_A 71
2ksd_A 48
5e1j_A 239
6snh_X 204
6edq_A 130
4bwz_A 236
4hw9_A 66
5c73_C 87
6hd8_B 130
5xls_A 241
6s7t_C 32
6rw9_A 67
4tkr_A 112
6qti_A 257
4p6v_D 116
5tj6_A 117
6e8j_A 278
2los_A 58
4cfg_A 39
4fc4_A 153
4huq_T 101
5aym_A 198
5l25_A 191
5c6o_A 262
2axt_C 108
6euq_A 203
2q7m_A 84
6igz_0 58
5wtr_A 151
6cnm_A 135
4j05_A 251
6n4b_R 155
6f0k_F 193
3a0b_Z 32
5c2t_D 76
3rko_M 206
4hwa_A 63
5zih_A 126
5gli_A 165
4mrn_A 131
6fos_2 59
3dl8_E 32
1pw4_A 253
5doq_A 142
6vrh_A 251
6nf6_A 259
4zw9_A 253
6hum_F 255
4cg4_B 41
6nsj_A 123
6c6l_O 38
6p9x_R 160
5n9y_A 37
6ksp_A 37
6a2w_A 65
5aww_G 27
1y8s_A 213
6jo5_B 159
4m64_B 242
4z7f_A 109
4he8_B 46
5wie_B 122
6p25_B 185
2mgy_A 104
3rko_N 208
5sy1_A 152
6c26_C 43
6btm_D 33
6rfq_b 29
6f36_A 34
5f5b_A 100
4atv_A 212
5gpj_A 280
3d31_C 117
4g7v_S 84
6f0k_D 39
6awf_C 66
1zc7_A 243
6uzz_A 128
3kp9_A 105
2d2c_B 47
3tdo_A 123
2loq_A 69
2ac6_A 155
6c6l_C 88
5gko_A 98
4il3_A 146
4us3_A 262
6bh8_A 131
3m71_A 181
3vou_A 41
6hja_A 77
5yhl_A 178
4xu4_A 108
4tqu_N 83
5lwe_A 173
6n1g_A 110
3qnq_A 166
6ijj_3 47
1zti_A 168
3pjz_A 239
1fx8_A 113
6sgz_D 28
5c6p_A 224
3wdo_A 253
2ks9_A 173
6tp3_A 172
6cfw_I 34
4h33_A 45
6a93_A 159
5yx9_A 107
6cfw_E 33
6adq_A 45
5dwy_A 183
3fh6_G 125
6quz_B 127
3wo7_A 92
3rko_L 243
1qle_C 116
6v8q_A 98
4p6v_B 157
5oqk_A 82
3gi8_C 232
5mg3_D 105
5azb_A 139
5h3o_A 134
6bug_C 187
5doq_B 142
2c10_A 20
6m96_B 112
6g9x_A 244
5ttp_A 131
5vkq_A 124
6ki1_A 224
5mg3_F 108
1mhs_A 212
4aq5_A 96
4lds_A 210
6nq0_A 226
4ezc_A 150
6f2d_G 31
5l75_G 154
6gs1_A 269
5bn2_A 110
2jln_A 186
6gy6_B 49
6rw8_A 73
5guw_B 238
3v5s_A 177
6o58_K 48
2lck_A 152
3jav_A 142
4a2n_B 90
6gps_A 151
6g2j_d 32
6nf4_A 248
5xpd_A 146
6fos_4 57
6e9n_A 233
1p49_A 47
5xam_A 226
5ek0_A 110
2mn6_B 31
6b3j_R 181
5fvn_A 147
1fft_C 73
5o9h_A 155
6ic4_G 90
4yms_D 137
3chx_B 105
1lvi_A 209
6rtc_A 192
6v1q_A 215
6roh_C 37
5khn_B 203
4tq3_A 164
6g2j_Y 64
5nf8_A 98
4px7_A 131
6i9k_A 169
6li2_A 151
6su3_X 161
1kyk_A 36
5ztf_A 198
6c14_B 95
3rko_K 42
4p6v_E 130
6puo_A 147
4o9p_D 146
6y1z_A 79
4in5_L 92
6cfw_D 51
5tbj_B 30
5ec5_A 22
5djq_C 39
5gar_N 131
6tjv_F 238
6h5a_A 100
3q7k_A 157
6r3q_A 246
5wuf_A 104
6cfw_C 50
5zdh_A 29
5zle_A 151
5oqt_A 210
6s3k_A 219
6nwd_A 162
6g94_A 103
6oh4_A 186
5iws_A 122
5ksd_A 217
3rko_A 41
5l22_B 140
5gjv_E 66
5tta_A 27
5mlz_A 89
5h1q_A 92
2bs2_C 125
6eu6_A 211
5xez_A 172
4he8_I 227
3hd6_A 226
6d0j_A 273
6adq_E 28
6rfq_L 44
5oc9_A 191
6d79_A 50
6c26_5 31
6ob6_A 186
5yck_A 281
3udc_A 60
5z1f_A 248
5gjv_A 417
6gxc_A 221
5ldw_N 168
5xjy_A 244
3egw_C 121
3b9w_A 211
6v22_E 37
4mes_A 128
2g1x_A 147
6cfw_H 233
1dw9_A 34
6c08_C 197
2acz_C 71
2lom_A 44
1xio_A 132
5eg1_A 144
6vq8_a 147
5cbf_A 54
6ov2_A 93
4pgr_A 141
5ckr_A 182
6a2j_A 199
2lor_A 33
6j5i_a 90
3pjs_K 41
5kbn_B 81
5yq7_L 91
6cfw_A 32
6h7d_A 245
6pgi_A 128
5nv9_A 246
5u70_A 144
6ebu_A 94
6gcs_3 48
6gcs_X 30
4bgn_A 104
2acz_D 75
5ctg_A 141
6adq_D 27
6bd4_A 160
6nt6_A 88
1kqf_C 82
6ukj_A 199
6peq_E 74
4he8_G 233
5guf_A 110
4ixq_A 79
6bhp_A 96
6mgv_A 274
4huq_S 30
5a63_B 136
4ikv_A 293
6p6i_A 103
4z34_A 166
6s7t_F 40
6a70_B 220
6idp_A 253
5l24_A 156
4bpm_A 76
3o7p_A 241
6pw4_A 126
2yev_C 35
5x5y_G 154
5ys3_A 97
5djq_A 260
3iyz_A 108
6roj_A 239
6oht_A 111
6iu3_A 113
5lqx_Y 48
4ntj_A 173
6f7h_A 120
5x3x_q 91
5c2t_C 73
4f4c_A 308
6hum_B 221
6ixg_A 46
3g6b_A 42
2k73_A 92
3a7k_A 122
5awz_A 162
6ibb_A 165
2gfz_A 160
6r7d_A 81
4p79_A 95
6k1h_Y 93
6gcs_1 134
3ayf_A 257
6dz7_B 229
4lp8_A 50
2f93_A 148
4q4a_A 134
5dn6_J 28
6p9y_R 181
6hug_C 86
5gyr_A 40
6ave_A 58
6baj_B 154
1pb4_D 63
5aex_A 226
4wd7_A 63
4qnd_A 64
4q65_A 251
6c26_2 42
6irs_B 215
4tqu_M 89
5vhw_A 43
6n38_D 67
6el1_O 44
6grj_G 50
4dxw_A 106
3j9p_D 142
6b85_J 46
1fft_B 31
6r6b_D 29
5x3x_m 69
5a1s_A 215
6hum_C 53
6gy6_A 28
2mpn_A 54
5gmy_A 191
2b6s_A 176
2g2a_A 135
6gcs_5 275
4x5m_B 64
4avm_A 73
4y7j_A 42
5twv_B 307
6sp2_A 157
6j8e_A 395
6pnj_A 162
6c6l_D 74
4z3n_A 250
5wpq_A 139
6cq6_A 118
6cse_M 197
5i6c_A 220
5c8j_I 75
6fv6_A 300
6hcy_C 119
4cz8_A 216
2m0q_A 46
5sv9_A 232
4k1c_A 211
4f35_B 168
6n3i_A 254
5sv0_B 70
5v4s_A 105
5gxb_A 223
3aou_A 82
5eul_A 25
5och_A 143
6uwm_A 110
5x5y_F 142
6s1k_E 26
5d0y_A 106
2prj_A 39
4kt0_K 37
3wmm_M 75
6ijj_L 55
5va2_A 120
3zux_A 197
5y4o_A 35
6u9v_A 49
5zgb_K 34
5v56_A 175
4v1f_A 47
4mnd_A 100
4hyj_A 161
3mp7_A 168
6f36_M 58
4knf_A 127
5uz7_R 175
3eh3_A 349
2wsw_A 223
5mke_A 146
6s7t_A 185
6m17_A 231
5tcx_A 75
4ry2_A 135
5dgy_A 177
4o6y_A 138
3dtu_A 317
2f75_A 145
4bem_J 56
2nq2_A 156
4o9p_C 46
6gcs_4 217
5u6o_A 129
3ixz_A 155
4b4a_A 112
5a40_A 86
3b4r_A 103
2aui_A 82
6cfw_M 144
4m58_A 139
1oed_B 89
2b0x_A 167
6a69_A 177
3cn5_A 110
2nr9_A 84
6c26_A 161
4xee_A 177
6s7t_H 44
6nd1_A 44
4chv_A 109
5xef_A 77
3mkt_A 235
1pb2_A 167
6bcj_B 117
6cfw_B 47
6tjv_D 213
6bbj_A 131
2amk_A 171
6hum_E 43
3nym_A 38
3rko_J 71
6rko_B 186
5z10_A 171
4zr0_A 73
6nc6_A 290
5v8k_A 150
4c9j_A 133
5i20_A 164
2ym0_A 44
1z8e_A 149
2yev_B 37
6vja_C 85
5zgb_O 29
5xmj_C 110
2iqp_A 163
5lx9_A 166
5b57_A 205
6s7t_D 41
6vq8_e 32
6gyh_A 151
6kg7_A 513
1u5n_A 209
4dve_A 87
4u4t_A 281
4av3_A 258
2gfp_A 210
5i32_A 116
5eiy_A 129
6ijj_6 48
4quv_A 173
5o0t_A 126
6iyu_A 162
6hra_A 172
6oly_A 48
6qwj_K 27
6gcs_6 81
6owx_A 30
4j7c_K 190
4mlb_A 276
4r1i_A 175
6f2g_A 262
3aym_A 149
5xu1_M 100
1p7b_A 49
6coy_A 244
3b5d_A 59
6qu1_A 47
6igz_2 49
6hum_G 80
6cc4_A 258
6cfw_F 59
5zji_O 29
4phz_A 28
1ar1_B 39
4hzu_S 28
6jbh_C 126
5do7_B 100
1oz5_A 128
4he8_D 81
5y83_A 66
6cjq_A 121
6n52_A 168
4a82_A 87
6umm_B 175
6cb2_A 100
4cad_C 138
6rag_A 120
6mhy_G 100
1dop_D 85
5dir_A 63
5jsi_A 151
6u1n_R 149
6j5i_b 32
6bo8_A 110
6dt0_A 47
5x9h_A 109
6vq8_f 30
5lki_A 47
6ijj_1 47
4xnv_A 177
3dhw_A 89
6jd2_A 92
6n40_A 251
6c96_A 215
3c02_A 109
6iiu_A 174
6r4l_A 232
6r6b_I 51
6fj3_A 136
5a63_C 122
6c3i_A 188
1yg7_A 251
5vkv_A 140
6f2d_F 28
6ji1_A 224
5fgn_A 95
4yzf_A 222
4rfs_S 33
3org_A 190
6c6l_M 39
1uwd_A 51
3jcu_S 51
2f95_B 27
3wmf_A 134
4gx0_A 44
6bbf_A 90
5mg3_C 80
5oc0_A 111
4od4_A 135
2evu_A 126
4ayw_A 147
3llq_A 118
6k7g_C 43
6kob_B 34
2oar_A 52
4ev6_A 42
5edl_A 134
此文件夹共有 707 个文件
Process finished with exit code 0