{"id":64,"date":"2017-04-06T17:48:59","date_gmt":"2017-04-06T17:48:59","guid":{"rendered":"http:\/\/lop.blogwyrm.com\/?p=64"},"modified":"2017-04-06T17:48:59","modified_gmt":"2017-04-06T17:48:59","slug":"file-server-scraping","status":"publish","type":"post","link":"https:\/\/lop.blogwyrm.com\/?p=64","title":{"rendered":"File Server Scraping"},"content":{"rendered":"<p>Within Python the best way to do file server scraping (or dumpster diving) is something like<\/p>\n<pre>def find_OpPt_CDFs(obs,ver,targ_dir):\r\n    file_pattern = re.compile('%s_d[ei]s\\d_engr_l1_sigthrsh_\\d{14}_v%s.cdf' % (obs,ver))\r\n        \r\n    print 'scraping in %s' % targ_dir\r\n \r\n    filtered_files = []\r\n    for root, dirs, files in os.walk(targ_dir):\r\n        for file in files:\r\n            if file_pattern.match(file):\r\n                full_filename = (root+'\/'+file).replace('\\\\','\/')\r\n                filtered_files.append(full_filename)\r\n    return np.array(filtered_files).flatten()\r\n<\/pre>\n<p>Note that the regex compile step uses:<\/p>\n<pre>\r\n    [ei] - either 'e' or 'i'\r\n    \\d   - digit\r\n    \\d{14} - any 14 digits in a row\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Within Python the best way to do file server scraping (or dumpster diving) is something like def find_OpPt_CDFs(obs,ver,targ_dir): file_pattern = re.compile('%s_d[ei]s\\d_engr_l1_sigthrsh_\\d{14}_v%s.cdf' % (obs,ver)) print 'scraping in %s' % targ_dir filtered_files = [] for root, dirs, files in os.walk(targ_dir): for file in files: if file_pattern.match(file): full_filename = (root+'\/'+file).replace('\\\\','\/') filtered_files.append(full_filename) return np.array(filtered_files).flatten() Note that the regex compile &hellip; <a href=\"https:\/\/lop.blogwyrm.com\/?p=64\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">File Server Scraping<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-64","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/lop.blogwyrm.com\/index.php?rest_route=\/wp\/v2\/posts\/64","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lop.blogwyrm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lop.blogwyrm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lop.blogwyrm.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lop.blogwyrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=64"}],"version-history":[{"count":3,"href":"https:\/\/lop.blogwyrm.com\/index.php?rest_route=\/wp\/v2\/posts\/64\/revisions"}],"predecessor-version":[{"id":67,"href":"https:\/\/lop.blogwyrm.com\/index.php?rest_route=\/wp\/v2\/posts\/64\/revisions\/67"}],"wp:attachment":[{"href":"https:\/\/lop.blogwyrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=64"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lop.blogwyrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=64"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lop.blogwyrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=64"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}