Issue creating Python script to batch convert .e00 files to shapefiles (.shp) with ArcGis 10.4.1

883
6
03-08-2018 01:26 AM
PeterStevens1
New Contributor

Hi there. 

I'm not only new to Python, but also to ArcGis and I'm quite stuck trying to create a script to batch convert .e00 files to .shp files.

I've started working with a script that I found in this very own site, but I'm not able to make it work properly. It seems that the first part of the code, where the conversion to coverage files is made, runs fine, but the second part, where the conversion to .shp files should be made, doesn't work. It just does anything.

I don't get any traceback erros. Could you please give me a hint? 

import arcpy, os 
arcpy.env.overwriteOutput = True 

arcpy.env.workspace = ws = r'C:\in' 
out = r'C:\out' 

if not os.path.exists(out): 
 os.makedirs(out) 

for cov in arcpy.ListFiles('.e00'): 
 arcpy.ImportFromE00_conversion(cov, ws, cov.split('.')[0]) 
 print 'Converted %s' %cov  

for cov in arcpy.ListFiles(): 
 if not '.e00' in cov and cov != 'info': 
  arcpy.env.workspace = os.path.join(ws,cov) 
  for fc in arcpy.ListFeatureClasses('*polygon'):
   shp = os.path.join(out, '%s.shp' %cov) 
   arcpy.FeatureClassToFeatureClass_conversion(fc, out) 
   print 'Converted Coverage to %s' %shp‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Thank you so much in advance.

0 Kudos
6 Replies
XanderBakker
Esri Esteemed Contributor

What does the print statement on line 12 yield (how many E00 files do you have and what are their names)? Can you include the result of the print statement in this thread?

Make sure that the E00 files do not have spaces, since those are not supported in the output coverage name.

Perhaps the second part does not find any results for using the ListFiles. You can use ListDatasets—Help | ArcGIS Desktop . instead on line 16:

for cov in arcpy.ListDatasets('*', 'Coverage'):

On line 17 you only search for polygon featureclasses in the coverage. Make sure that the coverage actually contains polygons. Otherwise it will not yield any result. I think after the first step you should be able to access and explore the coverages created and explore their content.

As a side note, E00 and coverages are a very dated data format. In many cases data providers have switched to more recent formats (like proprietary File Geodatabases). Check and see if perhaps a newer file format is available to avoid any conversions.

0 Kudos
PeterStevens1
New Contributor

Thank you, Xander. I really appreciate your help.

What does the print statement on line 12 yield (how many E00 files do you have and what are their names)? Can you include the result of the print statement in this thread?

 

Make sure that the E00 files do not have spaces, since those are not supported in the output coverage name.

I have a bunch of  E00 files located at the workspace folder. All files are named according to the following pattern: P0XXXX.E00 (P02000.E00, P02800.E00 and so on).  No spaces either.

The print statement on line 12 yields "Converted P02800.E00", so now that you mention it I've realized that it isn't batch converting every E00 files. 

Perhaps the second part does not find any results for using the ListFiles. You can use ListDatasets—Help | ArcGIS Desktop . instead on line 16:

I'll give it a try and I'll let you know. 

As a side note, E00 and coverages are a very dated data format. In many cases data providers have switched to more recent formats (like proprietary File Geodatabases). Check and see if perhaps a newer file format is available to avoid any conversions.

Thanks for the information. Sadly, I've been asked to work with tons of E00 files, so at least in the short term I have to deal with this data format.  

0 Kudos
RebeccaStrauch__GISP
MVP Esteemed Contributor

Peter, you (or a moderator of this thread) may want to covert this to a question.   Questions tend to get more views and responses.

i agree with Xander that goin to a file gdb might be better in the long run than a shape, but I understand the need for them at times.  With that said, what version if the software are you using?  If only Pro, that might be some of the issue, since even the print statements  should have ( ) around the values, and since this is older code, there are better ways than using the % for formatting.  

Although, not come plate samples from coverage to shape files, check out the help topics ..this is for 10.6, so may need to find the correct version. Import from E00—Help | ArcGIS Desktop      And Feature Class To Shapefile—Help | ArcGIS Desktop 

shapefiles themselves have have a lot of limits since the database portion is a .dbf so if there are long field names in the coverage  the field names  may be truncated to 10 characters and therefore you may get duplicate field names, which can toss an error.  This topic Geoprocessing considerations for shapefile output—Help | ArcGIS Desktop should help.

i am not in my office so can't end my code, but have converted many coverages in the past.  I prefer to go to a gdb. From there, you can always save back to a shape if needed.  This maybe a worksaround, or at least may be an easier way to look at the data to seem if they are hitting the limitations.  If need, you can then use field appoints to get the output you need.

hope this helps.

0 Kudos
PeterStevens1
New Contributor

Thank you, Rebecca. 

I'm not at the office right now, but as soon as I get there, I'll let you know what version of the software I'm exactly using. 

Until then, I'll dig into the documentation to learn more.

0 Kudos
PeterStevens1
New Contributor

Sorry for the delay in replying to you.

I'm using Python 2.7.5 with  ArcGIS 10.4.1 for Desktop Advanced, Product Version: 10.4.1.5686. 

I've tried to use ListDatasets instead of ListFiles without success. Since this is older code, I'm starting to think that it might be better to restart from scratch. 

Thanks again for your help, I truly appreciate it. 

0 Kudos
VinceAngelo
Esri Esteemed Contributor

If you're just starting with Python, there's really no reason to use anything but the correct indentation scheme -- 4 spaces. Making your code legible is just as important as including the complete error messages, or adding diagnostic arcpy.AddMessage() lines just inside each for loop to trace execution flow.

- V