<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Read and write python file using X and Y fields in the data. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199027#M65174</link>
    <description>&lt;P&gt;I have a json string that is being read from a word press API URL.... it looks like the attached.&lt;/P&gt;&lt;P&gt;I need to get this to a feature class.&amp;nbsp; In addition to all the fields, it only has an X and Y field which I have to convert to point geometry.&amp;nbsp; Any thoughts on how I can achieve this via Python?&lt;/P&gt;&lt;P&gt;So I need to read the URL for the json string then create a FC from it.&lt;/P&gt;&lt;P&gt;Python to Table and then Table to FC?&amp;nbsp; Any help would be appreciated.&lt;/P&gt;</description>
    <pubDate>Wed, 03 Aug 2022 17:11:33 GMT</pubDate>
    <dc:creator>jaykapalczynski</dc:creator>
    <dc:date>2022-08-03T17:11:33Z</dc:date>
    <item>
      <title>Read and write python file using X and Y fields in the data.</title>
      <link>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199027#M65174</link>
      <description>&lt;P&gt;I have a json string that is being read from a word press API URL.... it looks like the attached.&lt;/P&gt;&lt;P&gt;I need to get this to a feature class.&amp;nbsp; In addition to all the fields, it only has an X and Y field which I have to convert to point geometry.&amp;nbsp; Any thoughts on how I can achieve this via Python?&lt;/P&gt;&lt;P&gt;So I need to read the URL for the json string then create a FC from it.&lt;/P&gt;&lt;P&gt;Python to Table and then Table to FC?&amp;nbsp; Any help would be appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 17:11:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199027#M65174</guid>
      <dc:creator>jaykapalczynski</dc:creator>
      <dc:date>2022-08-03T17:11:33Z</dc:date>
    </item>
    <item>
      <title>Re: Read and write python file using X and Y fields in the data.</title>
      <link>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199053#M65175</link>
      <description>&lt;P&gt;There is a JSON to features arcpy method that should get you started. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/2.8/tool-reference/conversion/json-to-features.htm" target="_blank" rel="noopener"&gt;json-to-features&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 18:00:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199053#M65175</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-03T18:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: Read and write python file using X and Y fields in the data.</title>
      <link>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199054#M65176</link>
      <description>&lt;P&gt;@Anonymous User&amp;nbsp; did you look at my attachment... I am not sure how to specify the X Y field to get this to work... there is no geometry in the json file.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 18:03:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199054#M65176</guid>
      <dc:creator>jaykapalczynski</dc:creator>
      <dc:date>2022-08-03T18:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: Read and write python file using X and Y fields in the data.</title>
      <link>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199067#M65177</link>
      <description>&lt;P&gt;geometry_type is an optional parameter.&amp;nbsp; From the docs:&lt;/P&gt;&lt;P&gt;'The geometry type to convert from &lt;EM&gt;GeoJSON&lt;/EM&gt; to features. &lt;STRONG&gt;&lt;EM&gt;This option is only used when the input is a GeoJSON file&lt;/EM&gt;&lt;/STRONG&gt;. If the GeoJSON file does not contain any of the selected geometry type, the output feature class will be empty.'&lt;/P&gt;&lt;P&gt;Did you give the method a try with your json and see if the method is able to parse the x/y keys as long/lats?&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 18:20:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199067#M65177</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-03T18:20:42Z</dc:date>
    </item>
    <item>
      <title>Re: Read and write python file using X and Y fields in the data.</title>
      <link>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199083#M65179</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/50919"&gt;@jaykapalczynski&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;In addition to all the fields, it only has an X and Y field which I have to convert to point geometry.&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;ok, so the actual keys are 'site_longitude' and 'site_latitude' as the x/y and I assume that is what you are referencing. Thought you meant they were X and Y and didn't look that deeply.&lt;/P&gt;&lt;P&gt;After reading the initial JSON, iterate over the them to change the keys creating a new dictionary, and converted list. Something like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;converted_list = []
for json_dict in distr:
    json_dict['x'] = json_dict.pop('site_longitude')
    json_dict['y'] = json_dict.pop('site_latitude')
    converted_list.append(json_dict)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;convert back to JSON:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;json_object = json.dumps(converted_list) &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;then into the method JSON to features...&lt;/P&gt;&lt;P&gt;or use an insert cursor to insert the feature during the first iteration, mapping the site_long and site_lat to a point geometry and inserting it into the fc.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 18:50:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199083#M65179</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-03T18:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: Read and write python file using X and Y fields in the data.</title>
      <link>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199085#M65180</link>
      <description>&lt;P&gt;What is "myfeatures" referring to in the example you gave me?&amp;nbsp; I thought that it took 3 parameters and the third would be POINT, LINE, POLYGON etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;arcpy.conversion.JSONToFeatures(in_json_file, out_features, {geometry_type})&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EXAMPLE&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;arcpy.JSONToFeatures_conversion(&lt;/SPAN&gt;&lt;SPAN class=""&gt;"myjsonfeatures.json"&lt;/SPAN&gt;&lt;SPAN&gt;, os.path.join(&lt;/SPAN&gt;&lt;SPAN class=""&gt;"outgdb.gdb"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN class=""&gt;"myfeatures"&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 18:52:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199085#M65180</guid>
      <dc:creator>jaykapalczynski</dc:creator>
      <dc:date>2022-08-03T18:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: Read and write python file using X and Y fields in the data.</title>
      <link>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199090#M65182</link>
      <description>&lt;P&gt;Tried this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os
arcpy.env.workspace = "C:/Users/t/Desktop/JSONSamples/"
arcpy.JSONToFeatures_conversion("JSON.json", os.path.join("outgdb.gdb", "myfeatures"), {POINT})&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error:&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;File "C:/Users/tjv36463/Desktop/JSONSamples/AddPoints.py", line 4, in &amp;lt;module&amp;gt;&lt;BR /&gt;arcpy.JSONToFeatures_conversion("JSON.json", os.path.join("outgdb.gdb", "myfeatures"), {POINT})&lt;BR /&gt;NameError: name 'POINT' is not defined&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 18:59:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199090#M65182</guid>
      <dc:creator>jaykapalczynski</dc:creator>
      <dc:date>2022-08-03T18:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: Read and write python file using X and Y fields in the data.</title>
      <link>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199098#M65183</link>
      <description>&lt;P&gt;When reading the docs, items in {} mean they are optional.&amp;nbsp; They also have (Optional) listed under them in the parameter table.&amp;nbsp; If you don't have a value for it, you can omit it.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.JSONToFeatures_conversion("JSON.json", os.path.join("outgdb.gdb", "myfeatures"))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since the x,y keys have different names in the txt you provided, you'll have to do some manipulation before this method will work.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 19:07:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199098#M65183</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-03T19:07:13Z</dc:date>
    </item>
    <item>
      <title>Re: Read and write python file using X and Y fields in the data.</title>
      <link>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199102#M65184</link>
      <description>&lt;P&gt;If I do this I get this error&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os
arcpy.env.workspace = "C:/Users/t/Desktop/JSONSamples/"
outfeatureLocation = "C:/Users/t/Desktop/JSONSamples/OutputGeodatabase"
arcpy.JSONToFeatures_conversion("JSON.json", outfeatureLocation)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;Traceback (most recent call last):&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;File "C:/Users/t/Desktop/JSONSamples/AddPoints.py", line 7, in &amp;lt;module&amp;gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;arcpy.JSONToFeatures_conversion("JSON.json", outfeatureLocation)&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;File "C:\Program Files (x86)\ArcGIS\Desktop10.8\ArcPy\arcpy\conversion.py", line 602, in JSONToFeatures&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;raise e&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;ExecuteError: ERROR 001558: Error parsing json file 'JSON.json'. &lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;Failed to execute (JSONToFeatures).&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I do this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os
arcpy.env.workspace = "C:/Users/t/Desktop/JSONSamples/"
outfeatureLocation = "C:/Users/t/Desktop/JSONSamples/OutputGeodatabase"
arcpy.JSONToFeatures_conversion("JSON.json", os.path.join("outgdb.gdb"), 'POINT')
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;Traceback (most recent call last):&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;File "C:/Users/tjv36463/Desktop/JSONSamples/AddPoints.py", line 7, in &amp;lt;module&amp;gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;arcpy.JSONToFeatures_conversion("JSON.json", outfeatureLocation, 'POINT')&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;TypeError: JSONToFeatures() takes at most 2 arguments (3 given)&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 19:09:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199102#M65184</guid>
      <dc:creator>jaykapalczynski</dc:creator>
      <dc:date>2022-08-03T19:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: Read and write python file using X and Y fields in the data.</title>
      <link>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199120#M65186</link>
      <description>&lt;P&gt;Read the entire post- At the bottom it says "Since the x,y keys have different names in the txt you provided, &lt;STRONG&gt;you'll have to do some manipulation &lt;EM&gt;before this method will work&lt;/EM&gt;&lt;/STRONG&gt;."&amp;nbsp; I provided an example to get you started on how to do it in an earlier post.&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;To answer why these two didnt work as expected:&lt;/P&gt;&lt;P&gt;The first attempt, you have to load the file in as JSON using json.loads() or it doesn't know its JSON. It's saying it can't read it.&lt;/P&gt;&lt;P&gt;The second attempt, is because that parameter is only used for GeoJSON files, which your json is not GeoJSON. The method expects only 2 parameters for JSON files, as noted in the docs and in previous posts.&lt;/P&gt;&lt;P&gt;'The geometry type (the third parameter) to convert from &lt;EM&gt;GeoJSON&lt;/EM&gt; to features. &lt;STRONG&gt;&lt;EM&gt;This option is only used when the input is a GeoJSON file&lt;/EM&gt;&lt;/STRONG&gt;. If the GeoJSON file does not contain any of the selected geometry type, the output feature class will be empty.'&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 19:24:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199120#M65186</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-03T19:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: Read and write python file using X and Y fields in the data.</title>
      <link>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199141#M65190</link>
      <description>&lt;P&gt;OK this is what I have and getting another error.....sorry for my ignorance...tryin to learn here.&lt;/P&gt;&lt;P&gt;Its rewriting to the X and Y field names so thats good...&lt;/P&gt;&lt;P&gt;But getting error&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;Traceback (most recent call last):&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;File "C:/Users/t/Desktop/JSONSamples/AddPoints.py", line 44, in &amp;lt;module&amp;gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;arcpy.JSONToFeatures_conversion(json_object, os.path.join("outgdb.gdb", "myfeatures"))&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;File "C:\Program Files (x86)\ArcGIS\Desktop10.8\ArcPy\arcpy\conversion.py", line 602, in JSONToFeatures&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;raise e&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;ExecuteError: Failed to execute. Parameters are not valid.&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;ERROR 000814: Invalid file type&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;Failed to execute (JSONToFeatures).&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Do I have to convert the JSON Object to something before I use the&amp;nbsp; JSONToFeatures_conversion&lt;/LI&gt;&lt;LI&gt;Maybe its my output location and gdb.&amp;nbsp; I have a file gdb called&amp;nbsp;outgdb.gdb at the same location as where the python file is located.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import requests
import json
import uuid
import os

arcpy.env.workspace = "C:/Users/t/Desktop/JSONSamples/"
dataInput = r"C:/Users/t/Desktop/JSONSamples/JSON3.json"

f = open(dataInput)
data = json.load(f)
converted_list = []
for i in data['BirdTrailLocations']:

    i['x'] = i.pop('site_longitude')
    i['y'] = i.pop('site_latitude')
    converted_list.append(i)

    varsearchSiteID =  i["site_id"]
    varsearchSiteName =  i["site_name"]
    print ("site_id: " + varsearchSiteID)
    print ("site_name: " + varsearchSiteName)

    print ""

    print(i)

    print ""
  
# Closing file
f.close()

json_object = json.dumps(converted_list)

print json_object
print ""
print converted_list

outfeatureLocation = "C:/Users/t/Desktop/JSONSamples/OutputGeodatabase/"
arcpy.JSONToFeatures_conversion(json_object, os.path.join("outgdb.gdb", "myfeatures"))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 20:22:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199141#M65190</guid>
      <dc:creator>jaykapalczynski</dc:creator>
      <dc:date>2022-08-03T20:22:55Z</dc:date>
    </item>
    <item>
      <title>Re: Read and write python file using X and Y fields in the data.</title>
      <link>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199202#M65193</link>
      <description>&lt;P&gt;no worries... it looks like esri is pretty serious wanting an ESRI-JSON formatted JSON...&lt;/P&gt;&lt;P&gt;You can create this format similar to how we popped the out the site_long and site_lat.&amp;nbsp; Using your txt as an example but we build the geometry, fields, and attributes list:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;converted_list = []
for json_dict in distr:
    feat_dict = {} 
    feat_dict["geometry"] = {"x": json_dict["site_longitude"], "y": json_dict["site_latitude"]}
    # the list created a value type is incompatible with the field type. [site_facilities] so we nee dto convert it to a string
    json_dict["site_facilities"] = str(json_dict["site_facilities"])

    feat_dict["attributes"] = json_dict
    converted_list.append(feat_dict)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then create the dict that you will convert to esri-JSON, setting the fields to an item from the json and converted_list to the features:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;esri_json = {"geometryType" : "esriGeometryPoint",
             "spatialReference" : {"wkid" : 4326},
            'fields': [{"name": str(k), "type": "esriFieldTypeString", "alias": str(k), "length": 255} for k, v in distr[0].items()],
            'features': converted_list}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;which should give you something like the format they want:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;{'geometryType': 'esriGeometryPoint', 'spatialReference': {'wkid': 4326}, 

'fields': [{'name': 'site_id', 'type': 'esriFieldTypeString', 'alias': 'site_id', 'length': 255}, ...], 

'features': [{'geometry': {'x': '-77.581618', 'y': '37.44901'}, 'attributes': {'site_id': 'CAP01', 'site_name': 'Rockwood Park', 'site_loop': 'CAP', 'site_number': '1', ... }]}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;write it to a txt file on disk, or assign to a variable:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with open(r'C:\Users\...\Documents\ArcGIS\cnvrted.json', 'w') as f:
   json.dump(esri_json, f)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;json_object = json.dumps(esri_json)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then pass it to the method as before.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have another version that iterates over the json features using a an insert cursor that I can share but this method is more dynamic.&lt;/P&gt;&lt;P&gt;This gave me two points, and a lot of stuff in the attribute table.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 22:19:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199202#M65193</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-03T22:19:05Z</dc:date>
    </item>
    <item>
      <title>Re: Read and write python file using X and Y fields in the data.</title>
      <link>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199337#M65198</link>
      <description>&lt;P&gt;OK so great making progress here...&lt;/P&gt;&lt;P&gt;So I added/modified the code and its reading ok but not in the order you specified&lt;/P&gt;&lt;P&gt;I was wondering if that was OK????&lt;/P&gt;&lt;P&gt;You can see it writes &lt;STRONG&gt;Fields - geometry type - features - spatial reference&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But in the code I specified&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;esri_json = {"geometryType" : "esriGeometryPoint",
             "spatialReference" : {"wkid" : 4326},
            'fields': [{"name": str(k), "type": "esriFieldTypeString", "alias": str(k), "length": 255} for k, v in data[0].items()],
            'features': converted_list}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{'fields': [{'alias': 'site_name', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'site_name'}, {'alias': 'insects', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'insects'}, {'alias': 'site_number', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'site_number'}, {'alias': 'site_id', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'site_id'}, {'alias': 'seabirds', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'seabirds'}, {'alias': 'black_bear', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'black_bear'}, {'alias': 'site_ebird_url', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'site_ebird_url'}, {'alias': 'shorebirds', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'shorebirds'}, {'alias': 'loop_name', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'loop_name'}, {'alias': 'last_updated', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'last_updated'}, {'alias': 'lizards', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'lizards'}, {'alias': 'hawks', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'hawks'}, {'alias': 'frogs', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'frogs'}, {'alias': 'site_ebird_site_id', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'site_ebird_site_id'}, {'alias': 'site_access', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'site_access'}, {'alias': 'site_loop', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'site_loop'}, {'alias': 'site_season', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'site_season'}, {'alias': 'carto_id', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'carto_id'}, {'alias': 'cms_id', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'cms_id'}, {'alias': 'general_birding', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'general_birding'}, {'alias': 'phase', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'phase'}, {'alias': 'site_contact', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'site_contact'}, {'alias': 'site_latitude', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'site_latitude'}, {'alias': 'marine_mammals', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'marine_mammals'}, {'alias': 'bald_eagle', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'bald_eagle'}, {'alias': 'site_longitude', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'site_longitude'}, {'alias': 'site_website', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'site_website'}, {'alias': 'site_facilities', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'site_facilities'}, {'alias': 'site_description', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'site_description'}, {'alias': 'waterfowl', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'waterfowl'}, {'alias': 'grassland_birds', 'length': 255, 'type': 'esriFieldTypeString', 'name': 'grassland_birds'}], 'geometryType': 'esriGeometryPoint', 'features': [{'geometry': {'y': 37.44901, 'x': -77.581618}, 'attributes': {u'site_name': u'Rockwood Park', u'insects': u'Unknown', u'site_number': u'1', u'site_id': u'CAP01', u'seabirds': u'Na', u'black_bear': u'Unknown', u'site_ebird_url': u'https:ebird.orgbarchart?r=L617671&amp;amp;yr=all&amp;amp;m=', u'shorebirds': u'Na', u'loop_name': u'Appomattox Loop', u'last_updated': u'May 20, 2022', u'lizards': u'Unknown', u'hawks': u'Na', u'frogs': u'Unknown', u'site_ebird_site_id': u'L617671', u'site_access': u'Free, Daily', u'site_loop': u'CAP', u'site_season': u'All', u'carto_id': u'01', u'cms_id': u'4799', u'general_birding': u'Available', u'phase': u'Coastal Phase', u'site_contact': u'Chesterfield', u'site_latitude': 37.44901, u'marine_mammals': u'Na', u'bald_eagle': u'Unknown', u'site_longitude': -77.581618, u'site_website': u'&lt;A href="http://www.chesterfield.gov3824Rockwood-Park" target="_blank"&gt;www.chesterfield.gov3824Rockwood-Park&lt;/A&gt;', u'site_facilities': "[u'environmental_study_area', u'handicap_accessible', u'hiking_trails', u'information', u'interpretive_nature_program', u'parking', u'phone', u'picnic', u'restrooms']", u'site_description': u'This 160-acre', u'waterfowl': u'Na', u'grassland_birds': u'Unknown'}}], 'spatialReference': {'wkid': 4326}}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 12:35:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199337#M65198</guid>
      <dc:creator>jaykapalczynski</dc:creator>
      <dc:date>2022-08-04T12:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: Read and write python file using X and Y fields in the data.</title>
      <link>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199339#M65200</link>
      <description>&lt;P&gt;OK you can see my result in the other post... the resulting JSON is out of order as to what is specified in the python script....I am using this code to try and create the Feature Class but getting an error...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get this error:&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "C:/Users/t/Desktop/JSONSamples/AddPoints.py", line 47, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.JSONToFeatures_conversion(json_object, os.path.join("outgdb.gdb", "myfeatures"))&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.8\ArcPy\arcpy\conversion.py", line 602, in JSONToFeatures&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e&lt;/P&gt;&lt;P&gt;ExecuteError: Failed to execute. Parameters are not valid.&lt;/P&gt;&lt;P&gt;ERROR 000814: Invalid file type&lt;/P&gt;&lt;P&gt;Failed to execute (JSONToFeatures).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import requests
import json
import uuid
import os

arcpy.env.workspace = "C:/Users/t/Desktop/JSONSamples/"

dataInput = r"C:/Users/t/Desktop/JSONSamples/JSON4.json"

f = open(dataInput)
data = json.load(f)

data1 = {"BirdTrailLocations":  data }

converted_list = []
for i in data1['BirdTrailLocations']:
    
    feat_dict = {} 
    feat_dict["geometry"] = {"x": i["site_longitude"], "y": i["site_latitude"]}
    # the list created a value type is incompatible with the field type. [site_facilities] so we nee dto convert it to a string
    i["site_facilities"] = str(i["site_facilities"])

    feat_dict["attributes"] = i
    converted_list.append(feat_dict)

# Closing file
f.close()

esri_json = {"geometryType" : "esriGeometryPoint",
             "spatialReference" : {"wkid" : 4326},
            'fields': [{"name": str(k), "type": "esriFieldTypeString", "alias": str(k), "length": 255} for k, v in data[0].items()],
            'features': converted_list}

json_object = json.dumps(esri_json)

print json_object
print ""

arcpy.JSONToFeatures_conversion(json_object, os.path.join("outgdb.gdb", "myfeatures"))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 12:42:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199339#M65200</guid>
      <dc:creator>jaykapalczynski</dc:creator>
      <dc:date>2022-08-04T12:42:58Z</dc:date>
    </item>
    <item>
      <title>Re: Read and write python file using X and Y fields in the data.</title>
      <link>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199347#M65201</link>
      <description>&lt;P&gt;I just do not think I am getting to the outgdb.gdb correctly.... I think this is a pathing issue?&amp;nbsp; Not sure&lt;/P&gt;&lt;P&gt;c:/Users/t/Desktop/JSONSamples/outgdb.gdb&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 13:16:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199347#M65201</guid>
      <dc:creator>jaykapalczynski</dc:creator>
      <dc:date>2022-08-04T13:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: Read and write python file using X and Y fields in the data.</title>
      <link>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199349#M65202</link>
      <description>&lt;P&gt;I found out this morning JSONToFeatures wants a file so you'll need to write it to disk and load it from there.&amp;nbsp; I did a little bit of data cleanup using an update cursor, which I assume would be your next step once you got the data loaded.&amp;nbsp; You can alter fields from TEXT to other datatypes as well if you want.&lt;/P&gt;&lt;P&gt;Edit to note: You'll need to import re for some regex to fix the values.&amp;nbsp; I think your gdb path is ok and the order is ok, I truncated my esri_json a bit to avoid redundancy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;converted_list = []
for json_dict in distr:
    feat_dict = {}
    feat_dict["geometry"] = {"x": json_dict["site_longitude"], "y": json_dict["site_latitude"]}
    # the list created a value type is incompatible with the field type. [site_facilities] so we nee dto convert it to a string
    json_dict["site_facilities"] = str(json_dict["site_facilities"])
    feat_dict["attributes"] = json_dict
    converted_list.append(feat_dict)

new_dict = {"geometryType" : "esriGeometryPoint",
             "spatialReference" : {"wkid" : 4326},
            'fields': [{"name": str(k), "type": "esriFieldTypeString", "alias": str(k), "length": 255} for k, v in distr[0].items()],
            'features': converted_list}

print(new_dict)

esri_json = r'C:\Users\...\Documents\ArcGIS\cnvrted.json'

with open(esri_json, 'w') as f:
    json.dump(new_dict, f)

output_fc = r'C:\Users\...\Documents\ArcGIS\Projects\Clerk_LocalData\Clerk_LocalData.gdb\test'

arcpy.JSONToFeatures_conversion(esri_json, output_fc)

#####  Clean up the fields.
flds = [f.name for f in arcpy.ListFields(output_fc)]

p_tag = re.compile(r'.*?&amp;gt;(.*)&amp;lt;')

def extract_p_tag(invalue):
    result = p_tag.search(invalue)
    newVal = result.group(1)
    arcpy.AddMessage(f'Fixing: {invalue} to {newVal}')
    return newVal

def fix_website(invalue):
    newVal = re.sub(r'/', r'\\', invalue)
    newVal = newVal.replace('\\\\', '\\')
    arcpy.AddMessage(f'Fixing: {invalue} to {newVal}')
    return str(newVal)

def fix_facilities(invalue):
    newVal = invalue.replace('[', '').replace(']', '').replace(r"'", r'')
    arcpy.AddMessage(f'Fixing: {invalue} to {newVal}')
    return newVal

def fix_na(invalue):
    newVal = invalue.replace('\/', '\\')
    arcpy.AddMessage(f'Fixing: {invalue} to {newVal}')
    return str(newVal)

with arcpy.da.UpdateCursor(output_fc, flds) as uCur:
    for row in uCur:
        row[flds.index('site_description')] = extract_p_tag(row[flds.index('site_description')])
        row[flds.index('site_website')] = fix_website(row[flds.index('site_website')])
        row[flds.index('site_ebird_url')] = fix_website(row[flds.index('site_ebird_url')])
        row[flds.index('site_facilities')] = fix_facilities(row[flds.index('site_facilities')])
        row[flds.index('seabirds')] = fix_na(row[flds.index('seabirds')])

        uCur.updateRow(row)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 13:24:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199349#M65202</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-04T13:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: Read and write python file using X and Y fields in the data.</title>
      <link>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199357#M65203</link>
      <description>&lt;P&gt;@Anonymous User wow thanks man... very appreciated...&lt;/P&gt;&lt;P&gt;Can you elaborate on:&amp;nbsp;&lt;EM&gt;You'll need to import re for some regex to fix the values&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Not sure what this is.... a simple Import re or do I need to install something&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 13:29:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199357#M65203</guid>
      <dc:creator>jaykapalczynski</dc:creator>
      <dc:date>2022-08-04T13:29:46Z</dc:date>
    </item>
    <item>
      <title>Re: Read and write python file using X and Y fields in the data.</title>
      <link>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199359#M65204</link>
      <description>&lt;P&gt;no problem, re is the regex module I used to extract text between the &amp;lt;p&amp;gt; tags in line 32 &amp;amp; 33 in that last post.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import requests
import json
import uuid
import os
import re&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 13:32:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199359#M65204</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-04T13:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: Read and write python file using X and Y fields in the data.</title>
      <link>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199522#M65210</link>
      <description>&lt;P&gt;OK so I am trying to clean up the data and &lt;STRONG&gt;all&lt;/STRONG&gt; the reformats work fine &lt;STRONG&gt;except&lt;/STRONG&gt; this one...&lt;/P&gt;&lt;P&gt;thoughts?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR:&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;File "C:\Users\t\Desktop\JSONSamples\AddPoints.py", line 104, in &amp;lt;module&amp;gt;&lt;BR /&gt;row[flds.index('site_description')] = extract_p_tag(row[flds.index('site_description')])&lt;BR /&gt;File "C:\Users\tjv36463\Desktop\JSONSamples\AddPoints.py", line 77, in extract_p_tag&lt;BR /&gt;newVal = result.group(1)&lt;BR /&gt;AttributeError: 'NoneType' object has no attribute 'group'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#####  Clean up the fields.
flds = [f.name for f in arcpy.ListFields(output_fc)]

p_tag = re.compile(r'.*?&amp;gt;(.*)&amp;lt;')

def extract_p_tag(invalue):
    result = p_tag.search(invalue)
    newVal = result.group(1)
    #arcpy.AddMessage(f'Fixing: {invalue} to {newVal}')
    print 'Fixing p Tag ' + result + ' to ' + newVal
    print ""
    return newVal&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 17:45:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199522#M65210</guid>
      <dc:creator>jaykapalczynski</dc:creator>
      <dc:date>2022-08-04T17:45:13Z</dc:date>
    </item>
    <item>
      <title>Re: Read and write python file using X and Y fields in the data.</title>
      <link>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199528#M65211</link>
      <description>&lt;P&gt;That means the regex didn't find a result in one of the values, (the value didn't have any &amp;lt;p&amp;gt; tags).&amp;nbsp; You'll need to check for Nulls, and return the original value.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;if result:
    newVal = result.group(1)
else:
   newVal = invalue&lt;/LI-CODE&gt;&lt;P&gt;or as one liner:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;newVal = result.group(1) if result else invalue&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 17:57:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/read-and-write-python-file-using-x-and-y-fields-in/m-p/1199528#M65211</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-04T17:57:53Z</dc:date>
    </item>
  </channel>
</rss>

