POST
|
I've managed to get the Field_Mapping working, but as a massively complex (hard to read) parameter to the Merge_management tool - see below, so it does seem that it is possible to use field mapping with CSVs. arcpy.Merge_management("rg_Layer;ox_Layer;sn_Layer;sp_Layer", GISLive_GISADMIN_AA_TEST_70, "Postcode \"Postcode\" true true false 255 Text 0 0 ,First,#,rg_Layer,Field1,-1,-1,ox_Layer,Field1,-1,-1,sn_Layer,Field1,-1,-1,sp_Layer,Field1,-1,-1;Quality \"Quality\" true true false 4 Long 0 0 ,First,#,rg_Layer,Field2,-1,-1,ox_Layer,Field2,-1,-1,sn_Layer,Field2,-1,-1,sp_Layer,Field2,-1,-1;POBox \"POBox\" true true false 255 Text 0 0 ,First,#,rg_Layer,Field3,-1,-1,ox_Layer,Field3,-1,-1,sn_Layer,Field3,-1,-1,sp_Layer,Field3,-1,-1;TotalDPS \"TotalDPS\" true true false 4 Long 0 0 ,First,#,rg_Layer,Field4,-1,-1,ox_Layer,Field4,-1,-1,sn_Layer,Field4,-1,-1,sp_Layer,Field4,-1,-1;ResDPS \"ResDPS\" true true false 4 Long 0 0 ,First,#,rg_Layer,Field6,-1,-1,ox_Layer,Field6,-1,-1,sn_Layer,Field6,-1,-1,sp_Layer,Field6,-1,-1;ComDPS \"ComDPS\" true true false 4 Long 0 0 ,First,#,rg_Layer,Field7,-1,-1,ox_Layer,Field7,-1,-1,sn_Layer,Field7,-1,-1,sp_Layer,Field7,-1,-1;POBoxDPS \"POBoxDPS\" true true false 4 Long 0 0 ,First,#,rg_Layer,Field8,-1,-1,ox_Layer,Field8,-1,-1,sn_Layer,Field8,-1,-1,sp_Layer,Field8,-1,-1;Matched \"Matched\" true true false 4 Long 0 0 ,First,#,rg_Layer,Field9,-1,-1,ox_Layer,Field9,-1,-1,sn_Layer,Field9,-1,-1,sp_Layer,Field9,-1,-1;Unmatched \"Unmatched\" true true false 4 Long 0 0 ,First,#,rg_Layer,Field10,-1,-1,ox_Layer,Field10,-1,-1,sn_Layer,Field10,-1,-1,sp_Layer,Field10,-1,-1;XCoord \"XCoord\" true true false 4 Long 0 0 ,First,#,rg_Layer,Field11,-1,-1,ox_Layer,Field11,-1,-1,sn_Layer,Field11,-1,-1,sp_Layer,Field11,-1,-1;YCoord \"YCoord\" true true false 4 Long 0 0 ,First,#,rg_Layer,Field12,-1,-1,ox_Layer,Field12,-1,-1,sn_Layer,Field12,-1,-1,sp_Layer,Field12,-1,-1;PCType \"PCType\" true true false 255 Text 0 0 ,First,#,rg_Layer,Field19,-1,-1,ox_Layer,Field19,-1,-1,sn_Layer,Field19,-1,-1,sp_Layer,Field19,-1,-1")
... View more
02-22-2016
02:44 AM
|
0
|
0
|
339
|
POST
|
It is ironic that it ends up more complex using Field_Mapping, I wanted to use it to keep things simply.
... View more
02-22-2016
02:42 AM
|
0
|
0
|
339
|
POST
|
I am using arcpy.Merge_management to combine 4 CSV files into SDE. I attempting to use fieldmappings to rename the field headers, and this is causing it to crash. I've not used fieldmapping with more than two datasets simaltaneously before... The error is trapped by the try loop, but is returning no information. Any help would be appreciated. try: if booContinue == True: fieldmappings = arcpy.FieldMappings() fieldmap1 = arcpy.FieldMap() fieldmappings.addTable(rg_Layer) fieldmappings.addTable(ox_Layer) fieldmappings.addTable(sn_Layer) fieldmappings.addTable(sp_Layer) fieldmap1.addInputField(rg_Layer,"field1") fieldmap1.addInputField(ox_Layer,"field1") fieldmap1.addInputField(sn_Layer,"field1") fieldmap1.addInputField(sp_Layer,"field1") fieldout1 = fieldmap1.outputField fieldout1.name = "PCODE" fieldmap1.outputField = fieldout1 fieldmappings.addFieldMap(fieldmap1) arcpy.Merge_management([rg_Layer,ox_Layer,sn_Layer,sp_Layer], pc_layer, fieldMappings) msg = msg + "\n" + outname + " created" except: msg = msg + "\n" + "error creating " + outname + " - " + "\n" + arcpy.GetMessages(2) booContinue = False
... View more
02-17-2016
08:06 AM
|
0
|
4
|
2009
|
POST
|
Duncan The format was messed up when I pasted the code in. I'd actually already tidied it up a bit! I've given it a bit of a tidy up. Regards Chris
... View more
07-16-2015
03:13 AM
|
1
|
1
|
339
|
POST
|
Thanks Freddie that is really appreciated. VB.Net version of the code below. Dim booHdrive As Boolean = False Dim pGxObjCont As IGxObjectContainer Dim intFolders As Integer Dim pGxCatalog As IGxCatalog pGxCatalog = New GxCatalog If pGxCatalog Is Nothing Then Exit Sub Else pGxObjCont = pGxCatalog.GetObjectFromFullName("Folder Connections", intFolders) End If Dim pEnumGxObj As IEnumGxObject pEnumGxObj = pGxObjCont.Children If Not pEnumGxObj Is Nothing Then Dim pGxObj As IGxObject pGxObj = pEnumGxObj.Next Do While Not pGxObj Is Nothing If pGxObj.FullName = "H:\" Then booHdrive = True End If pGxObj = pEnumGxObj.Next Loop End If
... View more
07-13-2015
12:46 AM
|
1
|
0
|
339
|
POST
|
Does anybody have an arcObjects sample that will list the connect folders a user has created? This is as close as I've got; Dim pGxObjCont As IGxObjectContainer Dim pGxCatalog As IGxCatalog pGxCatalog = New GxCatalog If pGxCatalog Is Nothing Then Exit Sub Else pGxObjCont = pGxCatalog End If Dim pEnumGxObj As IEnumGxObject pEnumGxObj = pGxObjCont.Children Dim pGxObj As IGxObject pGxObj = pEnumGxObj.Next Do While Not pGxObj Is Nothing If pGxObj.Name = "Folder Connections" Then '### Get the individual folders here End If pGxObj = pEnumGxObj.Next Loop
... View more
07-10-2015
07:57 AM
|
0
|
5
|
2998
|
POST
|
ArcMap does not support casting of data fields at all except in pure SQL statements. The tool input that are not where clauses are not SQL based. The field is string and that is all ArcMap can use it as. ArcMap can only create a new field that is numeric. It cannot do anything to make your string field numeric. This limitation has been complained about by every user for over a decade and ESRI won't take it on. You have to convert it at the database level apart from any ESRI tools. ESRI won't write tools to do that for you. You are stuck either creating new fields or disconnected copies of the entire data table using Table to Table to recast the field to numeric inside of ArcMap. ESRI makes sure everything else results in errors. Only a purely text based input like a cvs or txt file is converted to numeric by the tool on the fly. If it detects that the input is a true data table it won't do that. You would not be the first person ESRI told to suck it up and make major schema changes outside of their product to make their product work and you won't be the last. Data conversions to make ESRI tools work feels like it is practically 50% of my job to use ArcMap at all if I have to deal with any data created outside of ArcMap by people who did not care about ESRI's data rules. The only benefit of being forced to adhere to these strict requirements is that adhering to their rules does translate into the best performance once I make the conversions. When ESRI attempts to accommodate such conversions on the fly the performance degradation is usually so severe I end up making the database level conversions anyway to stay sane. In fact I won't use Excel, cvs or txt files without conversion even though they are supported, because the performance boost of using a real numeric field in a real database table is dramatic and inevitably these formats impose some use restriction that I cannot live with at some point if the data inside of them is at all valuable for my job. Although it isn't the answer I wanted it at least gives me a clear answer, some times it is good to establish the limitations. Regards Chris
... View more
02-26-2014
04:13 AM
|
0
|
0
|
386
|
POST
|
float( !XField!) is what you have to use from the calculate field tool. If you running it right in python, try this: float(Xstr) Where Xstr is your X value as a string. Here is the Python line I've tested with; arcpy.MakeXYEventLayer_management(LLPG_Commercial_View, float("UNI72LIVE.PR_BLPU.MAP_EAST"), float("UNI72LIVE.PR_BLPU.MAP_NORTH"), LLPG_Commercial2_Layer, "", "") Here is the error returned; ValueError: could not convert string to float: UNI72LIVE.PR_BLPU.MAP_EAST It looks like it is trying to convert the fieldname rather than the values in the field.
... View more
02-25-2014
11:27 PM
|
0
|
0
|
386
|
POST
|
Are you trying to make points with the X and Y fields? Or are they simple to be used as a data field for your records? You could use the Add Field tool to make two numeric X and Y fields and then use the Calculate field tool to convert the string field to a number. You could probably skip the add field tool if you are confident that all the records will convert without error. Your expression could be something like: float( !XField!) Let me know if that helps at all. I tried this from a Python version of the code. I didn't work it gave me syntax errors.
... View more
02-25-2014
06:37 AM
|
0
|
0
|
386
|
POST
|
That's my bad. Missed it. Well... I wonder if you can perform the conversion directly in the SQL as part of the MakeQueryLayer_management implementation. I will hunt around to see if there are examples. My thought is, can you issue a "CAST" or "TO_NUMBER" statement in the sql somewhere? Edit: I noticed that you are attempting to implement MakeQueryTable! Man, that stuff just looks messy. If it were me, I'd go towards python script and implement the cx_Oracle library --- you have so much more control. I know that is outside of the bounds for your OP and sorry I don't have a good solution other than this. BUT, the cx_Oracle lib is very awesome 🙂 Conversion directly in the SQL would be the ideal solution, the model would be alot similiar and the load would be placed on the dB server. I will be exporting the script to Python at some point as it will be run on schedule each night, so the cx_Oracle lib is an option...
... View more
02-25-2014
05:53 AM
|
0
|
0
|
614
|
POST
|
How exactly are you "sucking in" the Oracle data as you mentioned in your OP? Apologies, I should have included that info. as it is important; I'm using the Make Query Table tool.
... View more
02-25-2014
05:42 AM
|
0
|
0
|
614
|
POST
|
Fix the database, it's that important. I just see no value in doing gymnastics to wrestle things that should be modeled for what they are at the database tier. If it's a date, store it as such. Decimals, floats, integers? Then that's what they are period. Get with the database admin, and make it right. You will save yourself tons of headaches, not just in the immediate, but long-term life-cycles of the tools and applications you build will be better off. Unfortunately this isn't an option as it is an third party application database. Any tampering would breach our support agreement 😞
... View more
02-25-2014
05:38 AM
|
0
|
0
|
614
|
POST
|
Yes I'm going to use table to create an event layer, which is why I'm wanting to convert the field type. I've tried using the Add Field Tool, but it throws an error on a table created with the Make Query Table tool. Although it wouldn't be my first choice to solve this problem, I ought to be possible to convert on the fly 😞 I'll try your suggestion of converting within the Make XT Event Layer and see what happens. I'll report back here with the results.
... View more
02-25-2014
05:36 AM
|
0
|
0
|
614
|
POST
|
Hello I'm creating a model that is sucking in data from an Oracle database, which I intend to turn into an Event Layer. Usually this is pretty simple, however on this occation the X and Y coordinates have been stored as strings. Is it possible to convert field data types when bringing in the data with the Make Query Table tool. Clearly if I was using straight SQL to the database I could do that)? All help and suggestions appreciated. Regards Chris
... View more
02-21-2014
06:01 AM
|
0
|
21
|
1959
|
POST
|
Wayne Many thanks for all your input and suggestions. I've finally resolved this issue... I've updated my Expression on the Calculate Value tool and added double quotes around the Start_Date variable, as follows; x(str("%Start_Date%"),str(%dblYears%)) From my experience in other programming languages I would assume that this would that this would create a string variable equal to the name of the object in the quotes, but not in this case!
... View more
01-09-2014
12:10 AM
|
0
|
0
|
662
|
Title | Kudos | Posted |
---|---|---|
1 | 07-13-2015 12:46 AM | |
1 | 07-16-2015 03:13 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|