Getting data with python

703
2
04-07-2014 01:28 AM
DorienJanssen
New Contributor
I'm trying to write a python program, in which python searches for files on an external harddrive. I can get python to tell me whether the files exist, but not to retrieve them. I'm rookie with python so I hope somebody can help me.

The files the program has to retrieve are raster datasets and are used in a model builder program then. The complete modelbuilder program works, the python part does not.

I hope somebody will be able to help me

Dorien Janssen
Tags (2)
0 Kudos
2 Replies
JamesCrandall
MVP Frequent Contributor

#specify the workspace rasters are located in
ws = "H:\Documents\ArcGIS\Default.gdb"
arcpy.env.workspace = ws

#for each Raster in the workspace, do something
rasters = arcpy.ListRasters()
for r in rasters:
  desc = arcpy.Describe(r)
  rastername = desc.Name
  print "Raster Name: %s" % (rastername)

0 Kudos
PatrickJurgens
New Contributor III
Are you hoping to copy the data from your removable drive to your local HDD? if so, then you should use the shutil module

import shutil
sourcefile = r'E:\path\to\file\example.ext'
destinationfile = r'C:\path\to\where\File\gets\copied\copy_example.ext'
shutil.copy(sourcefile, destinationfile)
0 Kudos