You are here: > ESRI Forums > arcgis desktop discussion forums > Thread Replies

ArcGIS Desktop Discussion Forums

ArcGIS Desktop - ArcCatalog Data Creation & Import/Export forum

Export / conversion of Shapefile : SHP to C...   skotea skotea Jun 10, 2005
Re: Export / conversion of Shapefile : SHP...   Kevin Sigwart Jun 10, 2005
Re: Export / conversion of Shapefile : SHP...   skotea skotea Jun 10, 2005
Re: Export / conversion of Shapefile : SHP...   Kevin Sigwart Jun 10, 2005
Re: Export / conversion of Shapefile : SHP...   Dan Patterson Jun 10, 2005
Re: Export / conversion of Shapefile : SHP...   skotea skotea Jun 10, 2005
Re: Export / conversion of Shapefile : SHP...   Dan Patterson Jun 10, 2005
Re: Export / conversion of Shapefile : SHP...   skotea skotea Jun 11, 2005
Re: Export / conversion of Shapefile : SHP...   Dan Patterson Jun 11, 2005
Re: Export / conversion of Shapefile : SHP...   skotea skotea Jun 11, 2005
Re: Export / conversion of Shapefile : SHP...   Dan Patterson Jun 11, 2005
Re: Export / conversion of Shapefile : SHP...   skotea skotea Jun 11, 2005
Re: Export / conversion of Shapefile : SHP...   Dan Patterson Jun 12, 2005
Re: Export / conversion of Shapefile : SHP...   skotea skotea Jun 13, 2005
Re: Export / conversion of Shapefile : SHP...   james ferguson Mar 24, 2006
Re: Export / conversion of Shapefile : SHP...   Dan Patterson Mar 24, 2006
Re: Export / conversion of Shapefile : SHP...   Amy Stuart Apr 20, 2006
Re: Export / conversion of Shapefile : SHP...   Graham Hayes Sep 26, 2006
Re: Export / conversion of Shapefile : SHP...   Erin Nock Mar 13, 2007
Re: Export / conversion of Shapefile : SHP...   Brian Cragin Feb 29, 2008
Re: Export / conversion of Shapefile : SHP...   Brian Cragin Mar 06, 2008
Re: Export / conversion of Shapefile : SHP...   Richard Kos Oct 02, 2008
Re: Export / conversion of Shapefile : SHP...   Amit Kulkarni Feb 24, 2009
Re: Export / conversion of Shapefile : SHP...   R Gale Apr 22, 2010
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Export / conversion of Shapefile : SHP to CSV or XML (shp2csv / shp2xml) 
Author skotea skotea 
Date Jun 10, 2005 
Message Hi,

I'm trying to export a SHP file to a human readable text file of X/Y points as CSV or XML (I prefer not to get MIF).

Any suggestion of a free standalone app or something for ArcMap 9.x ?

TIA

scott

PS : the only shp2csv app. i found was in japanese language and i didn't understand if i could download it and how... 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Export / conversion of Shapefile : SHP to CSV or XML (shp2csv / shp2xml) 
Author Kevin Sigwart 
Date Jun 10, 2005 
Message Scott,
If i understand your question; you are looking to export the table of the shapefile as a csv file. If this is true this is how i do it.

Open up your attribute table of you shapefile
Go to options --> Export
Export as a DBF file
Open dbf file with Microsoft EXCEL
Then save as csv

Hope this is helpful,
Kevin Sigwart 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Export / conversion of Shapefile : SHP to CSV or XML (shp2csv / shp2xml) 
Author skotea skotea 
Date Jun 10, 2005 
Message hi,

I don't want to export the table of the shapefile as a csv file.

I want to export the shapefile itself as a csv file.

I mean I don't care about the data in the dbf file linked to the shapefile.
I need the X/Y coordinates data stored in the shp file (i don't know if it is clear enough ? :()

thanks anyway for your reply.

scott 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Export / conversion of Shapefile : SHP to CSV or XML (shp2csv / shp2xml) 
Author Kevin Sigwart 
Date Jun 10, 2005 
Message Im sorry i misinterpreted your question. All you need to do is create two fields. X and Y, then run a calculation on each field getting the X and Y coordinates. For more information check this thread.
http://forums.esri.com/Thread.asp?c=93&f=1149&t=92731&mc=2#msgid256449 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Export / conversion of Shapefile : SHP to CSV or XML (shp2csv / shp2xml) 
Author Dan Patterson 
Date Jun 10, 2005 
Message if you are willing to dive into python, then create a tool in ArcToolbox and use this script (read the header for tool requirements) 
  Geomatics, Carleton University, Ottawa, Canada 
  FeaturesToCSV.zip (opens in new window)
 
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Export / conversion of Shapefile : SHP to CSV or XML (shp2csv / shp2xml) 
Author skotea skotea 
Date Jun 10, 2005 
Message hi Dan,

i really think this python script is what i need, but when launching it i got an error (please, see code below)

Something (between "cmd.exe /C" and "C:\FEATUR~1.PY") isn't supposed to launch the Python interpreter ?
Did i miss something (some Python configuration) ?

TIA (again)

scott
 
 
Executing (FeaturesToCSV_6): FeaturesToCSV 
GIRCOM_region # C:\testtt
Start Time: Fri Jun 10 21:21:15 2005
Running script FeaturesToCSV...
Error in script FeaturesToCSV.
Error in executing: cmd.exe /C C:\FEATUR~1.PY  "GIRCOM_region" "#" "C:\testtt"

Failed to execute (FeaturesToCSV_6).
End Time: Fri Jun 10 21:21:19 2005 (Elapsed Time: 4,00 secs)

 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Export / conversion of Shapefile : SHP to CSV or XML (shp2csv / shp2xml) 
Author Dan Patterson 
Date Jun 10, 2005 
Message I have designed it to run from a tool in the interim, see the script header, add a tool, specify the parameters and their properties etc
#Properties (right-click on the tool and specify the following)
#General
# Name FeaturesToCSV
# Label Features to CSV
# Desc Produces a csv file which contains X, Y and Z/M (if present)
# along with optional attributes for all features in a feature
# class. Selections will be honored in the output if you desire
# a subset. An output projection can be specified as well, to
# project any longitude/latitude output to another coordinate system.
#Source script ScriptNameHere.py
#
#Parameter list
# Parameter Properties
# Display Name Data type Type Direction MultiValue
# argv[1] Input feature class Feature Layer Required Input No
# argv[2] Optional fields Field Optional Input Yes
# argv[3] Output text file Text file Required Output No 
  Geomatics, Carleton University, Ottawa, Canada 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Export / conversion of Shapefile : SHP to CSV or XML (shp2csv / shp2xml) 
Author skotea skotea 
Date Jun 11, 2005 
Message Hi Dan,

i've already done all settings you write in your python code... same error again and again...

other python scripts included in ArcToolBox (as "Spatial Statistics Tools/Utilities/Export feature attribute to ascii") work fine...

really don't know what i miss.
if you know where i may find a solution to my problem, it would be cool

thanks again

scott

PS : here is my shp file just to know if it works with you (if you have a little time to test it)
 
  GIRCOM_region.shp (opens in new window)
 
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Export / conversion of Shapefile : SHP to CSV or XML (shp2csv / shp2xml) 
Author Dan Patterson 
Date Jun 11, 2005 
Message Scott
You will need to zip the other parts of the shapefile as well (eg *.shp, *.dbf, *.shx and *.prj etc if you have others) 
  Geomatics, Carleton University, Ottawa, Canada 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Export / conversion of Shapefile : SHP to CSV or XML (shp2csv / shp2xml) 
Author skotea skotea 
Date Jun 11, 2005 
Message ok it is done
but i don't understand why these other files are needed as the data i want to extract are in the shp file (not in the dbf, neither in the shx)

thanks again

scott 
  scott.zip (opens in new window)
 
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Export / conversion of Shapefile : SHP to CSV or XML (shp2csv / shp2xml) 
Author Dan Patterson 
Date Jun 11, 2005 
Message Scott
I didn't bring over all the attributes, the zip contains a toolbox, the script (with documentation fixed...my apologies) and the text file.

In short a shapefile is the sum of its parts, at least the shp, dbf and shx are required in order to use (kindof like a car needing the body, the engine and some wheels :) ). Let me know if the toolbox works, this is first time I have tried to distribute a toolbox. I will have to provide some more testing to bring attributes over that contain null values (not there yet).
Dan 
  Geomatics, Carleton University, Ottawa, Canada 
  Features2CSV.zip (opens in new window)
 
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Export / conversion of Shapefile : SHP to CSV or XML (shp2csv / shp2xml) 
Author skotea skotea 
Date Jun 11, 2005 
Message Dan, you've made a great job.

Your ToolBox works great and does exactly what I need : you save me a lot of time.

Thanks for everything (your time, your work, your patience and kindness).

Don't hesitate to give me your website address (if you have one) because i'll be very interested if you make updates for this script (especially to get attributes that contain null values).

Thanks again.
Regards.

scott (scottNOSPAM@alussinan.org - remove NOSPAM) 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Export / conversion of Shapefile : SHP to CSV or XML (shp2csv / shp2xml) 
Author Dan Patterson 
Date Jun 12, 2005 
Message Scott
turns out that no data entries are fine, I did notice that it fails as soon as an accent is hit in a string, so I am currenly exploring how the geoprocessor and/or python will allow for the conversion of various Unicodes within shapefile tables. I will post a followup on this forum or on arcscripts when I finish. 
  Geomatics, Carleton University, Ottawa, Canada 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Export / conversion of Shapefile : SHP to CSV or XML (shp2csv / shp2xml) 
Author skotea skotea 
Date Jun 13, 2005 
Message Hi Dan,

do you have any idea (or solution) to deal with Point class within the same python script ?

TIA

scott

PS : i'm rewritting a little part of your script to get excatly what i want (AGI (ArpentGIS) output file quiet simillar to XML) and it is clear, very well written and very understandable (THX again).

PPS : i think you have a small mistake in your script here : "isM = desc(fc).hasZ" (shouldn't it be "isM = desc(fc).hasM")

PPPS : <2D_GIS_newbie> if Z is for elevation, what is M for ?

PPPPS : you've made a (new) "optional output reference"... it is a great idea ! Is WGS 1984 coordinate system the same that is used by GPS ? 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Export / conversion of Shapefile : SHP to CSV or XML (shp2csv / shp2xml) 
Author james ferguson 
Date Mar 24, 2006 
Message Hi Dan,

I'm interested in using the python script you have written. I need to convert a polygon shape file to csv (string of coordinates) for input into an external system. However, when i downloaded the zip file you posted, winzip siad i was an invalid archive. Could you possibly post it again? 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Export / conversion of Shapefile : SHP to CSV or XML (shp2csv / shp2xml) 
Author Dan Patterson 
Date Mar 24, 2006 
Message try it again, I just downloaded and unzipped it 
  Geomatics, Carleton University, Ottawa, Canada 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Export / conversion of Shapefile : SHP to CSV or XML (shp2csv / shp2xml) 
Author Amy Stuart 
Date Apr 20, 2006 
Message The script is marvellous and exactly what I need! Thank you!

However, I would like to be able to use the script to loop through a directory of shapefiles and create csv files from all of the shapefiles. I would still like to be able to pick the attributes to export with the caveat that all of the shapefiles in the directory will have identical attributes.

I have tried using pieces of other code that I have found to loop through directories but I am very new to python so I am struggling with this and would appreciate any assistance.

Thanks! 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Export / conversion of Shapefile : SHP to CSV or XML (shp2csv / shp2xml) 
Author Graham Hayes 
Date Sep 26, 2006 
Message I've read through the threads but I have not found a link to download the shp2xml script. Could someone provide a link? 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Export / conversion of Shapefile : SHP to CSV or XML (shp2csv / shp2xml) 
Author Erin Nock 
Date Mar 13, 2007 
Message Help

I am trying to use the script but it cant execute...do I have the script stored in the wrong place...(In the properties box I set to where I downloaded it to)??

Erin 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Export / conversion of Shapefile : SHP to CSV or XML (shp2csv / shp2xml) 
Author Brian Cragin 
Date Feb 29, 2008 
Message Wondering if some one can address the issues with the script failing. I have read two different things when it comes to this error

Error in executing: cmd.exe /C C:\PROGRA~1\ArcGIS\ARCTOO~1\Scripts\FEATUR~2.PY

One thing I read was that it was a webroot spyware app running. The other was multiple versions of python running. Both of which I believe I have addressed. 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Export / conversion of Shapefile : SHP to CSV or XML (shp2csv / shp2xml) 
Author Brian Cragin 
Date Mar 06, 2008 
Message The output format seems to keep the X/Y values as some feet number. Changing projection doesn't do anything. Is there a way to get DD or DMS? 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Export / conversion of Shapefile : SHP to CSV or XML (shp2csv / shp2xml) 
Author Richard Kos 
Date Oct 02, 2008 
Message Hello - did you ever receive a reply to your post? i receive the same error message when I run the script and I'm sure it's stored in the proper location. Thanks! 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Export / conversion of Shapefile : SHP to CSV or XML (shp2csv / shp2xml) 
Author Amit Kulkarni 
Date Feb 24, 2009 
Message I have downloaded ur zip file and load that script.But when i run that script,it shows me error at output text file.It is saying that "Value is not valid,the value is not text file". Can u help me out for this? 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Export / conversion of Shapefile : SHP to CSV or XML (shp2csv / shp2xml) 
Author R Gale 
Date Apr 22, 2010 
Message Just a brief note of thanks for a very useful tool.