Export to CSV Attributes Shifted Fields

3371
9
05-08-2013 11:49 AM
NicholasGross
Occasional Contributor II
[ATTACH=CONFIG]24138[/ATTACH] [ATTACH=CONFIG]24137[/ATTACH]

When using the Export Selection to CSV tool included with the Silverlight Viewer, the resulting data in the CSV file is being shifted into the wrong fields (see screenshots). The 'District Code' field (the field that should contain 'I-2', 'RS-1', etc) is a short integer subtype field, and I'm wondering if that is somehow causing the problem. Also note, 'Zone District' and 'Zone Subdistrict' have default values that are dependent on the subtype field. Has anyone else run into this problem? Am I doing something wrong?
0 Kudos
9 Replies
IanPeebles
Regular Contributor
I noticed this a few months ago.  This is certainly a bug.  Based on the tests I have done, NULL values give problems.  There is no way we can guarantee not having NULL values.  Hopefully this problem is fixed soon.
0 Kudos
by Anonymous User
Not applicable
Original User: Bleroux

I too have run into this issue and it is the Null values as Ian has mentioned. I was able to work around this with my data by modifying my SQL that loads my tables to replace Nulls with some other value (0s or N/As).
0 Kudos
JosiahThoen
New Contributor II
I went through the code and it appears that when an empty field value is found a comma is appended to the cvs header row instead of the current records row.

Here is the source code: https://bitbucket.org/jdtblt/arcgis-fixedexportselectioncommand
here is the addin: https://bitbucket.org/jdtblt/arcgis-fixedexportselectioncommand/downloads

Add like any other addin:
Tools.xml
add the namespace:
xmlns:FixedExportSelectionCommand="clr-namespace:FixedExportSelectionCommand.AddIns;assembly=FixedExportSelectionCommand.AddIns" 


update the tool code:
[HTML]<Tool Label="Export Selection"
          Icon="Images/toolbar/ExportSelectionCommand16.png"
          Description="Export the attributes of selected features to a CSV file">
        <Tool.Class>
          <FixedExportSelectionCommand:ExportSelectionFixedCommand  />
        </Tool.Class>
      </Tool>[/HTML]

Application.xml
Add the extension:
<Extension Url="Extensions/FixedExportSelectionCommand.AddIns.xap" />
0 Kudos
by Anonymous User
Not applicable
Original User: Bleroux

Josiah- Out of curiosity, where did you get the source code for this? Also doesn't seem like you have anything to download but a readme file. Unless I am doing something worng.
0 Kudos
JosiahThoen
New Contributor II
I extracted the dll's from viewer.xap file.  Then used reflection to locate the ExportSelectionCommand code.  I then created a new project and implement the original ExportSelectionFixedCommand object and overrode the Execute method with the fixed code.  And then added the coded value domain lookup.
0 Kudos
by Anonymous User
Not applicable
Original User: winsleav

Worked perfectly- thank you. I was trying to find a fix on my own. You just saved me a ton of time.
0 Kudos
StevePickens
New Contributor
Downloaded and used the code. Works great. Cannot go back to back exports more if desired. i.e. Select 10 features and export to CSV. Clear Selection and select 10 more features and export to CSV causes "Error saving file". The file gets created but with 0 size and is empty. This does not happen with in the original Export to CSV code. Tried changing selection to different layers between exports and it doesn't fix the issue.

Any ideas?

Steve
0 Kudos
by Anonymous User
Not applicable
Original User: rzwaap

FYI, this bug is due to be fixed at the upcoming 3.2 release.  Sorry for the inconvenience.
0 Kudos
RichZwaap
Occasional Contributor III
Version 3.2 has been released and includes a fix for this issue.  You can download it from the Resource Center.
0 Kudos