Error exporting feature attributes

3936
13
10-24-2012 10:39 AM
steveSuperczynski
New Contributor
Has anyone else experienced any problems using the Export Feature Attributes to ASCII tool via python window?

I am using the following command yet it keeps telling me there is a syntax error, even though I followed the help on the tool syntax:

arcpy.ExportXYv_stats(infile,"State_Code";"County_Code";"Site_Code";"RASTERVALU","COMMA",outfile,"ADD_FIELD_NAMES")

-Steve
0 Kudos
13 Replies
T__WayneWhitley
Frequent Contributor
@Caleb - about keeping the Unicode characters, it's been awhile so I don't remember exactly what I did, but you have the option to write various text standard-compliant files, like utf-8 for example.  I took a look at using Python's codecs too I think.  Anyway, you can choose to keep the 'non-compliant' characters and write a unicode type text file - but then you may have problems in an app that adheres to the ANSI standard (which defeats the purpose of producing the file in the 1st place if you needed it as sort of an 'interoperable' solution).

At the very least, it was more useful not to crash the tool upon the mere encounter with non-ANSI characters, lol!  If I remember correctly, part of the exercise was trying to find out why some of the other tools were crashing too -- they were all choking on an apostrophe Unicode character, interesting but annoying.
I'll try to dig up and post what I put together that served the purpose at the time.
0 Kudos
by Anonymous User
Not applicable
@Wayne- Thanks for unicode the info.  If you find that example of when you do this I would definitely be interested in seeing it!

@Steve- I do not know what is with that tool, but I have a script that runs every night that uses the ExportXYv_stats tool and it will randomly crash once in a while even though I have made no changes.  So there must be some sort of bug with that tool.  I just found a potential flaw in my method of creating a CSV with a search cursor.  I do not know why but there seems to be an error with precision when writing these values out into a text file.

Screenshot 1 is a look at the table created by the XYv_stats table.  Screenshot 2 is the table created by my search cursor. 

[ATTACH=CONFIG]18743[/ATTACH][ATTACH=CONFIG]18742[/ATTACH]

I need to find a solution on how to fix this or as to why the values are changing.
0 Kudos
by Anonymous User
Not applicable
@Wayne- Thanks for the info about unicoding.  If you find the script where you did this operation I would definitely be interested in seeing it!

@Steve-  It does not make any sense as to why this tool is not working for you.  I have had problems with it too.  It is used in a script that I have running every night and it will decide to randomly crash out every once in a while even though I have not altered the script.  I did find one flaw in my search cursor method of writing out text files.  It appears that some precision errors are created when I use the search cursor to grab values and put them into a new text file.  Some of the values change by a very small amount (ex. 6.2 becomes 6.199999809).  So this may not be a good fix (it does work like a charm for exporting text values of course!).

I'll show you what I mean below.  Screenshot 1 is a csv created with the ExportXYv_stats tool (correct values).  Screenshot 2 is a csv created from the search cursor (some values are randomly off by very small amounts :confused:).  I am going to try to figure out why this is happening. 

[ATTACH=CONFIG]18744[/ATTACH][ATTACH=CONFIG]18745[/ATTACH]
0 Kudos
by Anonymous User
Not applicable
I figured out why I was having that problem...I was using the %s which is the string formatting (I should have known not to use this for float types!).  I found that when I replaced those with %f (float format) it worked perfectly.
0 Kudos