CloudStor is data storage service provided by AARNet. Individual researchers in AARNet connected institutions get 100gb of storage space for free, and research projects can apply for additional space.
We're using CloudStor to store and share high-resolution scans of Sydney Stock Exchange records from the Noel Butlin Archives at ANU. By my reckoning, there's 72,843 TIFF files, each weighing in at about 100mb. I'm going to be exploring ways of getting useful structured data out of the images, but as a first step I just wanted to be able to access data about the files.
CloudStor is an instance of OwnCloud, and OwnCloud provides WebDAV access, so I thought I'd have a go at using WebDAV to access file data on CloudStor.
It works, but there are a few tricks...
I'm using a Python WebDAV client. I installed it using pip
but ran into some problems with the dependencies. PyCurl complained that it didn't know what SSL library it was meant to use. Thanks to StackOverflow, I got it going with:
brew install curl --with-openssl
pip install --no-cache-dir --global-option=build_ext --global-option="-L/usr/local/opt/openssl/lib" --global-option="-I/usr/local/opt/openssl/include" --user pycurl
# Import what we need
import webdav.client as wc
import random
import pandas as pd
import time
import os
import pickle
from tqdm.auto import tqdm
from credentials import * # Storing my CloudStor credentials in another file
This was the thing that caused me most confusion.
First of all, you have to create a password in CloudStor to use with WebDAV. This is not the password that you use to access the CloudStor web interface (via the AAF).
This is the password you'll use with the WebDAV client. The WebDAV username is the email address you've used to register with CloudStor.
On the bottom left of the CloudStor web interface is another Settings link. If you click it it displays the url to use with WebDAV: https://cloudstor.aarnet.edu.au/plus/remote.php/webdav/
Originally, I just plugged this link in below as the webdav_hostname
and at first things seemed to work. I could list the contents of a directory, but I couldn't get resource information or download a file. Eventually, amongst the issues on the client's GitHub site, I found the answer. You have to separate the host from the path, and supply the path as webdav_root
.
# Set the connection options. CLOUDSTOR_USER and CLOUDSTOR_PW are stored in a separate credentials file.
options = {
'webdav_hostname': 'https://cloudstor.aarnet.edu.au',
'webdav_login': CLOUDSTOR_USER,
'webdav_password': CLOUDSTOR_PW,
'webdav_root': '/plus/remote.php/webdav/'
}
# Ok let's initiate the client.
client = wc.Client(options)
# Use .list() to get a list of resources in the directory
# In this case it's a list of subdirectories
dirs = client.list('Shared/ANU-Library/Sydney Stock Exchange 1901-1950/')
# For some reason the parent directory is included in the list, let's filter it out
# We'll also remove some old directories we don't want
dirs = [d for d in dirs if (d[:2] == 'AU') and '_old' not in d]
# Loop through all the subdirectories and use .list() again to get all the filenames
files = []
directories = []
for d in tqdm(dirs, desc='Directories'):
files = [f for f in client.list('Shared/ANU-Library/Sydney Stock Exchange 1901-1950/{}'.format(d)) if f[:1] == 'N']
# print('{}: {} files'.format(d, len(files)))
# Save the details for each subdirectory
summary.append({'directory': d, 'number': len(files)})
for f in tqdm(files, desc='Files', leave=False):
path = 'Shared/ANU-Library/Sydney Stock Exchange 1901-1950/{}{}'.format(d, f)
# This slows things down a lot, so disable for now
# info = client.info(path)
info = {}
info['name'] = f
info['directory'] = d
info['path'] = path
# print(info)
details.append(info)
time.sleep(0.5)
HBox(children=(IntProgress(value=0, description='Directories', max=199, style=ProgressStyle(description_width=…
HBox(children=(IntProgress(value=0, description='Files', max=303, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=312, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=345, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=312, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=305, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=334, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=349, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=318, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=327, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=327, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=350, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=310, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=330, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=329, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=349, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=313, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=331, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=322, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=348, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=312, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=330, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=314, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=344, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=310, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=323, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=332, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=349, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=314, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=328, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=327, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=339, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=316, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=329, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=322, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=351, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=317, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=300, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=328, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=350, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=320, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=325, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=318, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=344, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=317, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=331, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=317, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=350, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=314, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=296, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=338, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=351, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=314, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=326, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=315, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=167, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=315, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=318, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=309, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=347, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=313, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=317, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=312, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=345, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=309, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=317, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=307, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=343, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=313, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=310, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=325, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=352, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=296, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=321, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=314, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=348, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=306, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=331, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=309, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=351, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=318, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=281, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=333, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=350, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=312, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=315, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=307, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=349, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=316, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=306, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=316, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=343, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=319, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=325, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=301, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=351, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=317, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=314, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=308, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=346, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=318, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=316, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=314, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=352, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=313, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=320, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=312, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=351, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=310, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=331, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=310, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=345, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=317, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=305, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=326, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=351, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=314, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=322, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=307, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=352, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=317, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=322, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=314, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=347, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=318, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=296, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=340, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=351, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=312, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=327, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=307, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=348, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=315, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=303, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=309, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=390, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=366, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=375, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=366, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=418, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=371, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=381, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=374, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=417, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=366, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=359, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=605, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=621, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=564, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=585, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=555, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=623, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=555, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=600, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=573, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=606, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=559, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=579, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=606, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=633, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=556, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=593, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=571, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=633, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=600, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=439, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=408, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=429, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=414, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=417, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=408, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=428, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=392, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=437, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=393, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=426, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=384, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=394, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=400, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=411, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=384, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=405, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=379, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=264, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=389, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=397, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=387, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=430, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=387, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=346, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=378, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=489, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=468, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=488, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=468, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=520, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=461, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=496, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=468, style=ProgressStyle(description_width='initi…
HBox(children=(IntProgress(value=0, description='Files', max=89, style=ProgressStyle(description_width='initia…
# How many files are there?
len(details)
72932
# Get some information on individual files
client.info('Shared/ANU-Library/Sydney Stock Exchange 1901-1950/{}/{}'.format('AU NBAC N193-001', 'N193-001_0001.tif'))
{'created': None, 'name': None, 'size': '106240746', 'modified': 'Wed, 13 Jun 2018 01:56:48 GMT'}
I saved the results as CSV files — one for files and one for directories.
# Save previously downloaded data as CSV files so that I don't have to do it again
# I use Pandas for these conversions because it's easy
df_files = pd.DataFrame(details)
df_files.to_csv('files.csv', index=False)
df_dirs = pd.DataFrame(summary)
df_dirs.to_csv('directories.csv', index=False)
# Load previously harvested data
files = pd.read_csv('files.csv').to_dict('records')
directories = pd.read_csv('directories.csv').to_dict('records')
To do some testing on the images, I wanted to download a random sample.
# First we'll make a random selection from the list of file names.
random_files = random.sample(files, 2000)
# freeze this sample for reuse
with open('random_sample.pickle', 'wb') as pickle_file:
pickle.dump(random_files, pickle_file)
# reload frozen sample
with open('random_sample.pickle', 'rb') as pickle_file:
random_files = pickle.load(pickle_file)
# Then we'll just loop through the randomly selected files and download them
for image in random_files:
print('Downloading {}'.format(image['name']))
dir = '/Volumes/bigdata/mydata/stockexchange/years/{}'.format(image['directory'].replace(' ', '-'))
if not os.path.exists(dir):
os.makedirs(dir)
filename = '{}/{}'.format(dir, image['name'])
if not os.path.exists(filename):
client.download_sync(remote_path=image['path'], local_path=filename)
def download_page(page, year, output_dir):
image_dir = os.path.join(output_dir, str(year))
os.makedirs(image_dir, exist_ok=True)
filename = '{}/{}'.format(image_dir, page.name)
if not os.path.exists(filename):
client.download_sync(remote_path=page.path, local_path=filename)
def download_by_year(year, output_dir):
df_dates = pd.read_csv('files_with_dates.csv')
for page in df_dates.loc[df_dates['year'] == year].itertuples():
download_page(page, year, output_dir)
download_by_year(1930, '/Volumes/bigdata/mydata/stockexchange/years')
Wondering how to access a public share? Have a look here...