POST
|
Modern Electric You're using Python 2.x which doesn't support 'newline'. Remove this newline='' then add the following at the end of the previous code. It should work now. file_object = open(outfile, 'r')
lines = csv.reader(file_object, delimiter=',', quotechar='"')
flag = 0
data=[]
for line in lines:
if line == []:
flag =1
continue
else:
data.append(line)
file_object.close()
if flag ==1: #if blank line is present in file
file_object = open(outfile, 'w')
for line in data:
str1 = ','.join(line)
file_object.write(str1+"\n")
file_object.close()
... View more
06-26-2020
11:03 AM
|
1
|
2
|
3837
|
POST
|
Hi Kathy Gillis, If you change the variables and run the following code you should get the intersected shapes, all in one feature class: arcpy.env.workspace = r"workspace path"
arcpy.analysis.Intersect("example_polys #", "example_polys_Intersect", "ALL", None, "INPUT")
... View more
06-26-2020
10:28 AM
|
2
|
2
|
2082
|
POST
|
Hi Evan Myers, Is your data spatially defined (or projected)? Is it possible to share your script? It looks like you're getting an error in this line too: with arcpy.da.UpdateCursor(fc,fields + ["SHAPE@"],"",cs) as ucur:
... View more
06-26-2020
09:44 AM
|
1
|
5
|
1322
|
POST
|
Modern Electric Try this one, it removes blank rows and you can specify which fields to output in the csv file: import arcpy
import csv, os
arcpy.env.overwriteOutput = True
workspace = r"working path"
gdb_fc = os.path.join(workspace, r"path to GDB Feature Class")
outfile = os.path.join(workspace, "output_data.csv")
fields = arcpy.ListFields(gdb_fc)
# for instance, you want to output just the following fields
fieldsToKeep = ['Tree_Type', 'Latitude', 'Longitude', 'Tree_Height', 'Note']
# field_names = [field.name for field in fields if field.name in fieldsToKeep]
with open(outfile,'w', newline='') as f:
w = csv.writer(f)
# w.writerow(field_names) **This is commented out to skip writing a header**
for row in arcpy.SearchCursor(gdb_fc):
field_vals = [row.getValue(field.name) for field in fields if field.name in fieldsToKeep]
w.writerow(field_vals)
del row
... View more
06-26-2020
09:03 AM
|
0
|
4
|
3837
|
POST
|
That worked for me too. Thanks heaps Egge-Jan Pollé 's Blog.
... View more
06-25-2020
08:30 PM
|
1
|
0
|
1368
|
POST
|
Hi Modern Electric Here's the code that exports a File GDB Table to a .CSV file WithOut the Header Row and it also overrides the existing file in it's place with the same name. import arcpy
import csv, os
arcpy.env.overwriteOutput = True
workspace = r"working path"
gdb_fc = os.path.join(workspace, r"path to GDB Feature Class")
outfile = os.path.join(workspace, "output_data.csv")
fields = arcpy.ListFields(gdb_fc)
field_names = [field.name for field in fields]
with open(outfile,'w') as f:
w = csv.writer(f)
# w.writerow(field_names) **This is commented out to skip writing a header**
for row in arcpy.SearchCursor(gdb_fc):
field_vals = [row.getValue(field.name) for field in fields]
w.writerow(field_vals)
del row
... View more
06-25-2020
08:05 AM
|
1
|
1
|
3837
|
POST
|
Hi, I'm trying to send a filled-out survey form which is linked to Workforce (mobile apps) but I get the Send Error message which says “This survey was not able to be sent due to the following error: Database error has occurred.” I have created the surveys and all is shared and accessible to relative members in Portal. When I run it in my desktop survey app there is no problem sending it to Portal. Any idea or advice? Thank you.
... View more
04-24-2020
12:46 AM
|
0
|
3
|
1753
|
POST
|
Hi, I'm trying to generate a token from a Portal url. It generates a token when pasting this link into a web browser: https://portalUrl/sharing/rest/generateToken?&f=json but when I run this code: function getToken(portalUrl, username, password) {
var xmlhttp = new XMLHttpRequest();
var url = "https://portalUrl/sharing/rest/generateToken?username=username&password=password&f=json";
xmlhttp.open("POST", url, false);
xmlhttp.send();
if (xmlhttp.status == 200) {
var responseJSON = JSON.parse(xmlhttp.responseText)
if (responseJSON && !responseJSON.error) {
return responseJSON.token;
} else {
return "ERROR";
}
} else {
return "ERROR"
}
} I get an error. and I've created this in XHR code too: var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://portalUrl/sharing/rest/generateToken?username=username&password=password&f=json");
xhr.send(); and this throws the following error: {"error":{"code":400,"message":"Unable to generate token.","details":["POST request should not contain username and password in the query string."]}} Any ideas or help is appreciated. Thank you.
... View more
03-26-2020
01:10 AM
|
0
|
2
|
4247
|
POST
|
Hi, I'm trying to get the following code running. This code is a copy from this link: CreateSharingDraft—Sharing module | ArcGIS Desktop import arcpy
import os
# Set output file names
outdir = r"C:\Project\Output"
service = "MapServiceDraftExample"
sddraft_filename = service + ".sddraft"
sddraft_output_filename = os.path.join(outdir, sddraft_filename)
# Reference map to publish
aprx = arcpy.mp.ArcGISProject(r"C:\Project\World.aprx")
m = aprx.listMaps("World")[0]
# Create MapServiceDraft and set service properties
service_draft = arcpy.sharing.CreateSharingDraft("STANDALONE_SERVER", "MAP_SERVICE", service, m)
service_draft.targetServer = r"C:\Project\myserver.ags.esri.com (publisher).ags"
# Create Service Definition Draft file
service_draft.exportToSDDraft(sddraft_output_filename)
# Stage Service
sd_filename = service + ".sd"
sd_output_filename = os.path.join(outdir, sd_filename)
arcpy.StageService_server(sddraft_output_filename, sd_output_filename)
# Share to portal
print("Uploading Service Definition...")
arcpy.UploadServiceDefinition_server(sd_output_filename, r"C:\Project\myserver.ags.esri.com (publisher).ags")
print("Successfully Uploaded service.") I've changed the variable accordingly, however I get this error even though I can connect to the server (.ags) in ArcGIS Pro: Are there any other options besides "STANDALONE_SERVER" in service_draft = arcpy.sharing.CreateSharingDraft("STANDALONE_SERVER", "MAP_SERVICE", service, m)? Thanks.
... View more
01-14-2020
12:22 AM
|
0
|
1
|
1053
|
POST
|
Hi Victor Tey Unfortunately, this is still not available in 2.4 version of ArcGIS Pro SDK. For more information refer to the link below: ProGuide TableControl · Esri/arcgis-pro-sdk Wiki · GitHub
... View more
10-03-2019
12:37 AM
|
0
|
0
|
634
|
POST
|
Hi Rachel, I've configured the Notebook Server with Portal to use a Domain certificate. I've also federated the Notebook Server and designated it.
... View more
09-17-2019
06:43 PM
|
0
|
0
|
1017
|
POST
|
Hi, I just installed ArcGIS Enterprise 10.7.1 with the Notebook Server. Docker Desktop is running and I also downloaded and pulled the esri docker images (Advanced and Standard). The server is also federated and designated. However, when I click the Notebook on Portal for ArcGIS, it throws this error (screenshot below): I also added a notebook from Add Item, same error. and when I'm going to create a notebook via Create button in My Content, nothing happens. Any ideas? Thank you.
... View more
09-04-2019
12:45 AM
|
0
|
2
|
1200
|
POST
|
Hi Maxime Campeau, you can update a view layer with a new definition query but I don't think you can create a view layer from another view layer. For more information about how to update the viewDefinitionQuery property you can refer to the link below about "Using the ArcGIS API for Python to create a view from a Hosted Feature Layer and to define a view definition" by Earl Medina: https://community.esri.com/groups/arcgis-python-api/blog/2019/02/11/using-the-arcgis-api-for-python-to-create-a-view-from-a-hosted-feature-layer-and-to-define-a-view-fefinition
... View more
08-19-2019
01:09 AM
|
0
|
0
|
3203
|
POST
|
Hi Peter Gamberg, you can use the following code to check the credits availability for each user: #Checking credits assigned and available to a user
api_acc = gis.users.get('USERNAME')
"""When you turn on credit budgeting (using the enable() method),
the User object gets additional properties to
indicate the assignedCredits and remaining avialableCredits.
Thus, you can verify as shown below:"""
api_acc.assignedCredits
------------------------------------------------------------------------------
api_acc.availableCredits
"""As the user continues to use the credits, the availableCredits
property can be used to check how much is available for that account.
If a user does not have a limit set, then the total available credits
in the org become their available credits. The account shown below as
not custom limit, hence, it inherits the org's total limit."""
... View more
08-18-2019
11:14 PM
|
1
|
0
|
2694
|
Title | Kudos | Posted |
---|---|---|
1 | 11-10-2020 04:59 PM | |
1 | 02-08-2021 09:29 PM | |
1 | 02-17-2021 04:47 PM | |
1 | 03-15-2024 02:35 AM | |
1 | 09-15-2021 06:18 PM |