I have a Python file in /Users/homedir/...
and I want it to access a csv
file on an external hard drive.
Does anyone know how to do this? I only need reading permission.
First, connect the drive by USB. Double-click the USB hard drive icon to open up a Finder window and browse its contents. Click Finder > Devices to see a small icon of the external hard drive when plugged in. Click to select it and show its contents in Finder.
Have you ever wondered that you can open your drives by just typing C, D or E and then that drives are open. This can be possible by using Python. So, for performing this task this we are using os. startfile() method of OS library.
External drives can be found under /Volumes on macOS. If you provide the full path and have read access you should be able to read in your csv.
I have USB connected WD 4 TB hard drive that appears as "My Passport for Mac" in finder. I have created a folder called model on this drive and stored a file called model.json
Here is code to read the file.
import os
import sys
# load json and create model
json_file = open('/Volumes/My Passport for Mac/model/model.json', 'r')
loaded_model_json = json_file.read()
json_file.close()
My Mac Mini has 121 GB SSD which I find limiting when I work with huge data for ML exercises. I used to keep getting messages such as "low volume. clean up your disk " often and then I had to clean the files. To work around I bough 4 TB external HD from WD and attached it to MAC mini via USD. I put all my data files and models onto this drive now and it works fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With