In [1]:
import os
import subprocess
In [2]:
import datetime
time_start = datetime.datetime.now()
print time_start
2015-02-07 20:04:20.352856

In [3]:
BASEDIR = "/home/efg/2015/Kaggle/Plankton/train"

# DIRWALK = [dirpath, direnames, filenames]
DIRWALK = [fileNameDir for fileNameDir in os.walk(BASEDIR)]
In [4]:
#for i in range(len(DIRWALK)):  
#    print i, DIRWALK[i][0], DIRWALK[i][1], len(DIRWALK[i][2])

Count files by type by training directory

In [5]:
total_sig = 0
total_tif = 0

for i in range(len(DIRWALK)):
    print i, DIRWALK[i][0], DIRWALK[i][1], len(DIRWALK[i][2]), 
    count_sig = 0
    count_tif = 0
    for j in range(len(DIRWALK[i][2])):
        filename = DIRWALK[i][2][j]
        suffix = filename.rsplit(".",2)[1]
        if   suffix == "sig":
            count_sig += 1
        elif   suffix == "tif":
            count_tif += 1
        else:
            print "Unexpected suffix in", filename
    print count_sig, count_tif
    total_sig += count_sig
    total_tif += count_tif

print "Grand total counts", total_sig, total_tif
0 /home/efg/2015/Kaggle/Plankton/train ['appendicularian_slight_curve', 'chaetognath_other', 'hydromedusae_typeE', 'copepod_calanoid_large_side_antennatucked', 'copepod_calanoid_flatheads', 'shrimp-like_other', 'protist_dark_center', 'decapods', 'echinoderm_larva_pluteus_urchin', 'heteropod', 'acantharia_protist_big_center', 'hydromedusae_typeD_bell_and_tentacles', 'ctenophore_lobate', 'unknown_unclassified', 'protist_other', 'fish_larvae_medium_body', 'copepod_calanoid_large', 'copepod_calanoid_octomoms', 'hydromedusae_shapeB', 'echinoderm_larva_pluteus_early', 'hydromedusae_h15', 'copepod_cyclopoid_oithona_eggs', 'invertebrate_larvae_other_B', 'ctenophore_cydippid_tentacles', 'hydromedusae_liriope', 'detritus_blob', 'copepod_cyclopoid_copilia', 'hydromedusae_narco_young', 'siphonophore_calycophoran_sphaeronectes_young', 'unknown_sticks', 'siphonophore_calycophoran_sphaeronectes_stem', 'tunicate_doliolid', 'fish_larvae_leptocephali', 'trichodesmium_multiple', 'detritus_filamentous', 'tunicate_partial', 'fecal_pellet', 'hydromedusae_shapeA', 'siphonophore_calycophoran_rocketship_adult', 'radiolarian_chain', 'shrimp_zoea', 'tunicate_salp', 'trichodesmium_bowtie', 'copepod_calanoid_small_longantennae', 'hydromedusae_other', 'hydromedusae_typeF', 'protist_noctiluca', 'chaetognath_non_sagitta', 'echinoderm_larva_seastar_brachiolaria', 'pteropod_butterfly', 'echinopluteus', 'ephyra', 'ctenophore_cydippid_no_tentacles', 'artifacts_edge', 'echinoderm_seacucumber_auricularia_larva', 'trichodesmium_puff', 'protist_star', 'tunicate_salp_chains', 'echinoderm_larva_pluteus_typeC', 'artifacts', 'euphausiids_young', 'copepod_other', 'amphipods', 'diatom_chain_tube', 'siphonophore_physonect', 'hydromedusae_solmundella', 'chordate_type1', 'invertebrate_larvae_other_A', 'siphonophore_physonect_young', 'hydromedusae_haliscera', 'fish_larvae_myctophids', 'siphonophore_other_parts', 'hydromedusae_shapeA_sideview_small', 'siphonophore_partial', 'hydromedusae_typeD', 'siphonophore_calycophoran_sphaeronectes', 'pteropod_theco_dev_seq', 'protist_fuzzy_olive', 'chaetognath_sagitta', 'hydromedusae_bell_and_tentacles', 'shrimp_sergestidae', 'radiolarian_colony', 'echinoderm_larva_pluteus_brittlestar', 'stomatopod', 'pteropod_triangle', 'tunicate_doliolid_nurse', 'polychaete', 'hydromedusae_haliscera_small_sideview', 'detritus_other', 'copepod_cyclopoid_oithona', 'unknown_blobs_and_smudges', 'shrimp_caridean', 'hydromedusae_narco_dark', 'copepod_calanoid_eucalanus', 'appendicularian_straight', 'appendicularian_s_shape', 'hydromedusae_aglaura', 'crustacean_other', 'trochophore_larvae', 'siphonophore_calycophoran_rocketship_young', 'hydromedusae_partial_dark', 'echinoderm_larva_seastar_bipinnaria', 'acantharia_protist_halo', 'acantharia_protist', 'copepod_calanoid_frillyAntennae', 'diatom_chain_string', 'hydromedusae_narcomedusae', 'ctenophore_cestid', 'trichodesmium_tuft', 'copepod_calanoid', 'hydromedusae_solmaris', 'euphausiids', 'fish_larvae_very_thin_body', 'fish_larvae_thin_body', 'tornaria_acorn_worm_larvae', 'copepod_calanoid_eggs', 'hydromedusae_sideview_big', 'appendicularian_fritillaridae', 'siphonophore_calycophoran_abylidae', 'fish_larvae_deep_body', 'jellies_tentacles'] 0 0 0
1 /home/efg/2015/Kaggle/Plankton/train/appendicularian_slight_curve [] 1064 532 532
2 /home/efg/2015/Kaggle/Plankton/train/chaetognath_other [] 3868 1934 1934
3 /home/efg/2015/Kaggle/Plankton/train/hydromedusae_typeE [] 28 14 14
4 /home/efg/2015/Kaggle/Plankton/train/copepod_calanoid_large_side_antennatucked [] 212 106 106
5 /home/efg/2015/Kaggle/Plankton/train/copepod_calanoid_flatheads [] 356 178 178
6 /home/efg/2015/Kaggle/Plankton/train/shrimp-like_other [] 104 52 52
7 /home/efg/2015/Kaggle/Plankton/train/protist_dark_center [] 216 108 108
8 /home/efg/2015/Kaggle/Plankton/train/decapods [] 110 55 55
9 /home/efg/2015/Kaggle/Plankton/train/echinoderm_larva_pluteus_urchin [] 176 88 88
10 /home/efg/2015/Kaggle/Plankton/train/heteropod [] 20 10 10
11 /home/efg/2015/Kaggle/Plankton/train/acantharia_protist_big_center [] 26 13 13
12 /home/efg/2015/Kaggle/Plankton/train/hydromedusae_typeD_bell_and_tentacles [] 112 56 56
13 /home/efg/2015/Kaggle/Plankton/train/ctenophore_lobate [] 76 38 38
14 /home/efg/2015/Kaggle/Plankton/train/unknown_unclassified [] 850 425 425
15 /home/efg/2015/Kaggle/Plankton/train/protist_other [] 2344 1172 1172
16 /home/efg/2015/Kaggle/Plankton/train/fish_larvae_medium_body [] 170 85 85
17 /home/efg/2015/Kaggle/Plankton/train/copepod_calanoid_large [] 572 286 286
18 /home/efg/2015/Kaggle/Plankton/train/copepod_calanoid_octomoms [] 98 49 49
19 /home/efg/2015/Kaggle/Plankton/train/hydromedusae_shapeB [] 300 150 150
20 /home/efg/2015/Kaggle/Plankton/train/echinoderm_larva_pluteus_early [] 184 92 92
21 /home/efg/2015/Kaggle/Plankton/train/hydromedusae_h15 [] 70 35 35
22 /home/efg/2015/Kaggle/Plankton/train/copepod_cyclopoid_oithona_eggs [] 2378 1189 1189
23 /home/efg/2015/Kaggle/Plankton/train/invertebrate_larvae_other_B [] 48 24 24
24 /home/efg/2015/Kaggle/Plankton/train/ctenophore_cydippid_tentacles [] 106 53 53
25 /home/efg/2015/Kaggle/Plankton/train/hydromedusae_liriope [] 38 19 19
26 /home/efg/2015/Kaggle/Plankton/train/detritus_blob [] 726 363 363
27 /home/efg/2015/Kaggle/Plankton/train/copepod_cyclopoid_copilia [] 60 30 30
28 /home/efg/2015/Kaggle/Plankton/train/hydromedusae_narco_young [] 672 336 336
29 /home/efg/2015/Kaggle/Plankton/train/siphonophore_calycophoran_sphaeronectes_young [] 494 247 247
30 /home/efg/2015/Kaggle/Plankton/train/unknown_sticks [] 350 175 175
31 /home/efg/2015/Kaggle/Plankton/train/siphonophore_calycophoran_sphaeronectes_stem [] 114 57 57
32 /home/efg/2015/Kaggle/Plankton/train/tunicate_doliolid [] 878 439 439
33 /home/efg/2015/Kaggle/Plankton/train/fish_larvae_leptocephali [] 62 31 31
34 /home/efg/2015/Kaggle/Plankton/train/trichodesmium_multiple [] 108 54 54
35 /home/efg/2015/Kaggle/Plankton/train/detritus_filamentous [] 788 394 394
36 /home/efg/2015/Kaggle/Plankton/train/tunicate_partial [] 704 352 352
37 /home/efg/2015/Kaggle/Plankton/train/fecal_pellet [] 1022 511 511
38 /home/efg/2015/Kaggle/Plankton/train/hydromedusae_shapeA [] 824 412 412
39 /home/efg/2015/Kaggle/Plankton/train/siphonophore_calycophoran_rocketship_adult [] 270 135 135
40 /home/efg/2015/Kaggle/Plankton/train/radiolarian_chain [] 574 287 287
41 /home/efg/2015/Kaggle/Plankton/train/shrimp_zoea [] 348 174 174
42 /home/efg/2015/Kaggle/Plankton/train/tunicate_salp [] 472 236 236
43 /home/efg/2015/Kaggle/Plankton/train/trichodesmium_bowtie [] 1416 708 708
44 /home/efg/2015/Kaggle/Plankton/train/copepod_calanoid_small_longantennae [] 174 87 87
45 /home/efg/2015/Kaggle/Plankton/train/hydromedusae_other [] 24 12 12
46 /home/efg/2015/Kaggle/Plankton/train/hydromedusae_typeF [] 122 61 61
47 /home/efg/2015/Kaggle/Plankton/train/protist_noctiluca [] 1250 625 625
48 /home/efg/2015/Kaggle/Plankton/train/chaetognath_non_sagitta [] 1630 815 815
49 /home/efg/2015/Kaggle/Plankton/train/echinoderm_larva_seastar_brachiolaria [] 1072 536 536
50 /home/efg/2015/Kaggle/Plankton/train/pteropod_butterfly [] 216 108 108
51 /home/efg/2015/Kaggle/Plankton/train/echinopluteus [] 54 27 27
52 /home/efg/2015/Kaggle/Plankton/train/ephyra [] 28 14 14
53 /home/efg/2015/Kaggle/Plankton/train/ctenophore_cydippid_no_tentacles [] 84 42 42
54 /home/efg/2015/Kaggle/Plankton/train/artifacts_edge [] 340 170 170
55 /home/efg/2015/Kaggle/Plankton/train/echinoderm_seacucumber_auricularia_larva [] 192 96 96
56 /home/efg/2015/Kaggle/Plankton/train/trichodesmium_puff [] 3958 1979 1979
57 /home/efg/2015/Kaggle/Plankton/train/protist_star [] 226 113 113
58 /home/efg/2015/Kaggle/Plankton/train/tunicate_salp_chains [] 146 73 73
59 /home/efg/2015/Kaggle/Plankton/train/echinoderm_larva_pluteus_typeC [] 160 80 80
60 /home/efg/2015/Kaggle/Plankton/train/artifacts [] 786 393 393
61 /home/efg/2015/Kaggle/Plankton/train/euphausiids_young [] 76 38 38
62 /home/efg/2015/Kaggle/Plankton/train/copepod_other [] 48 24 24
63 /home/efg/2015/Kaggle/Plankton/train/amphipods [] 98 49 49
64 /home/efg/2015/Kaggle/Plankton/train/diatom_chain_tube [] 1000 500 500
65 /home/efg/2015/Kaggle/Plankton/train/siphonophore_physonect [] 256 128 128
66 /home/efg/2015/Kaggle/Plankton/train/hydromedusae_solmundella [] 246 123 123
67 /home/efg/2015/Kaggle/Plankton/train/chordate_type1 [] 154 77 77
68 /home/efg/2015/Kaggle/Plankton/train/invertebrate_larvae_other_A [] 28 14 14
69 /home/efg/2015/Kaggle/Plankton/train/siphonophore_physonect_young [] 42 21 21
70 /home/efg/2015/Kaggle/Plankton/train/hydromedusae_haliscera [] 458 229 229
71 /home/efg/2015/Kaggle/Plankton/train/fish_larvae_myctophids [] 228 114 114
72 /home/efg/2015/Kaggle/Plankton/train/siphonophore_other_parts [] 58 29 29
73 /home/efg/2015/Kaggle/Plankton/train/hydromedusae_shapeA_sideview_small [] 548 274 274
74 /home/efg/2015/Kaggle/Plankton/train/siphonophore_partial [] 60 30 30
75 /home/efg/2015/Kaggle/Plankton/train/hydromedusae_typeD [] 86 43 43
76 /home/efg/2015/Kaggle/Plankton/train/siphonophore_calycophoran_sphaeronectes [] 358 179 179
77 /home/efg/2015/Kaggle/Plankton/train/pteropod_theco_dev_seq [] 26 13 13
78 /home/efg/2015/Kaggle/Plankton/train/protist_fuzzy_olive [] 744 372 372
79 /home/efg/2015/Kaggle/Plankton/train/chaetognath_sagitta [] 1388 694 694
80 /home/efg/2015/Kaggle/Plankton/train/hydromedusae_bell_and_tentacles [] 150 75 75
81 /home/efg/2015/Kaggle/Plankton/train/shrimp_sergestidae [] 306 153 153
82 /home/efg/2015/Kaggle/Plankton/train/radiolarian_colony [] 316 158 158
83 /home/efg/2015/Kaggle/Plankton/train/echinoderm_larva_pluteus_brittlestar [] 72 36 36
84 /home/efg/2015/Kaggle/Plankton/train/stomatopod [] 48 24 24
85 /home/efg/2015/Kaggle/Plankton/train/pteropod_triangle [] 130 65 65
86 /home/efg/2015/Kaggle/Plankton/train/tunicate_doliolid_nurse [] 834 417 417
87 /home/efg/2015/Kaggle/Plankton/train/polychaete [] 262 131 131
88 /home/efg/2015/Kaggle/Plankton/train/hydromedusae_haliscera_small_sideview [] 18 9 9
89 /home/efg/2015/Kaggle/Plankton/train/detritus_other [] 1828 914 914
90 /home/efg/2015/Kaggle/Plankton/train/copepod_cyclopoid_oithona [] 1798 899 899
91 /home/efg/2015/Kaggle/Plankton/train/unknown_blobs_and_smudges [] 634 317 317
92 /home/efg/2015/Kaggle/Plankton/train/shrimp_caridean [] 98 49 49
93 /home/efg/2015/Kaggle/Plankton/train/hydromedusae_narco_dark [] 46 23 23
94 /home/efg/2015/Kaggle/Plankton/train/copepod_calanoid_eucalanus [] 192 96 96
95 /home/efg/2015/Kaggle/Plankton/train/appendicularian_straight [] 484 242 242
96 /home/efg/2015/Kaggle/Plankton/train/appendicularian_s_shape [] 1392 696 696
97 /home/efg/2015/Kaggle/Plankton/train/hydromedusae_aglaura [] 254 127 127
98 /home/efg/2015/Kaggle/Plankton/train/crustacean_other [] 402 201 201
99 /home/efg/2015/Kaggle/Plankton/train/trochophore_larvae [] 58 29 29
100 /home/efg/2015/Kaggle/Plankton/train/siphonophore_calycophoran_rocketship_young [] 966 483 483
101 /home/efg/2015/Kaggle/Plankton/train/hydromedusae_partial_dark [] 380 190 190
102 /home/efg/2015/Kaggle/Plankton/train/echinoderm_larva_seastar_bipinnaria [] 770 385 385
103 /home/efg/2015/Kaggle/Plankton/train/acantharia_protist_halo [] 142 71 71
104 /home/efg/2015/Kaggle/Plankton/train/acantharia_protist [] 1778 889 889
105 /home/efg/2015/Kaggle/Plankton/train/copepod_calanoid_frillyAntennae [] 126 63 63
106 /home/efg/2015/Kaggle/Plankton/train/diatom_chain_string [] 1038 519 519
107 /home/efg/2015/Kaggle/Plankton/train/hydromedusae_narcomedusae [] 264 132 132
108 /home/efg/2015/Kaggle/Plankton/train/ctenophore_cestid [] 226 113 113
109 /home/efg/2015/Kaggle/Plankton/train/trichodesmium_tuft [] 1356 678 678
110 /home/efg/2015/Kaggle/Plankton/train/copepod_calanoid [] 1362 681 681
111 /home/efg/2015/Kaggle/Plankton/train/hydromedusae_solmaris [] 1406 703 703
112 /home/efg/2015/Kaggle/Plankton/train/euphausiids [] 272 136 136
113 /home/efg/2015/Kaggle/Plankton/train/fish_larvae_very_thin_body [] 32 16 16
114 /home/efg/2015/Kaggle/Plankton/train/fish_larvae_thin_body [] 128 64 64
115 /home/efg/2015/Kaggle/Plankton/train/tornaria_acorn_worm_larvae [] 76 38 38
116 /home/efg/2015/Kaggle/Plankton/train/copepod_calanoid_eggs [] 346 173 173
117 /home/efg/2015/Kaggle/Plankton/train/hydromedusae_sideview_big [] 152 76 76
118 /home/efg/2015/Kaggle/Plankton/train/appendicularian_fritillaridae [] 32 16 16
119 /home/efg/2015/Kaggle/Plankton/train/siphonophore_calycophoran_abylidae [] 424 212 212
120 /home/efg/2015/Kaggle/Plankton/train/fish_larvae_deep_body [] 20 10 10
121 /home/efg/2015/Kaggle/Plankton/train/jellies_tentacles [] 282 141 141
Grand total counts 30336 30336

In [6]:
time_stop = datetime.datetime.now()
print time_stop
print (time_stop - time_start), "overall convert time"
2015-02-07 20:04:21.258656
0:00:00.905800 overall convert time