Select to view content in your preferred language

FeatureClassToGeodatabase in stand-alone script not working

1046
4
12-01-2020 12:38 PM
GabrielMarcus1
Frequent Contributor

I'm having problems with a stand-alone script that uses the FeatureClassToGeodatabase function. When executing it in the IDE, the print statement executes with the output below which looks correct. 

The code executes fine within the AGP python window, but doesn't work when executing from PyCharm. 

I'm not new to executing stand-alone scripts, but I can't figure this out!

 

 

 

 

 

homeDir = r"E:\ArcGIS\Projects\del_testingMDR"
fileName = r"del_testingMDR.aprx"
aprx = arcpy.mp.ArcGISProject(os.path.join(homeDir, fileName))
aprxMap = aprx.listMaps("Map")[0]

 

 

 

 

 

 

 

 

 

 

 

def AddSHPtoGDB(r):
    """
    :param r: function is called during iteration over region list. r is a single region string
    :return:
    """
    input_files = []
    for wx in wx_vars:
        for file in os.listdir(ndfd_output + "/" + r):
            if file.endswith(".shp"):
                if file.lower().startswith(wx.lower()):
                    input_files.append(os.path.join(ndfd_output, r, file))
        in_features = input_files
        out_location = r"E:\ArcGIS\Projects\del_testingMDR\wwa_Import.gdb"
        arcpy.FeatureClassToGeodatabase_conversion(in_features,out_location)
        print("adding {} to {}".format(in_features,out_location))

 

 

 

 

 

 

 

 

 

 

 

in_features
['C:\\ndfd\\degrib\\output\\conus\\WWA_12011800.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12011900.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12012000.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12012100.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12012200.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12012300.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12020000.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12020100.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12020200.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12020300.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12020400.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12020500.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12020600.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12020700.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12020800.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12020900.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12021000.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12021100.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12021200.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12021300.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12021400.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12021500.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12021600.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12021700.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12021800.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12021900.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12022000.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12022100.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12022200.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12022300.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12030000.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12030100.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12030200.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12030300.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12030400.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12030500.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12030600.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12030700.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12030800.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12030900.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12031000.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12031100.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12031200.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12031300.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12031400.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12031500.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12031600.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12031700.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12031800.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12031900.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12032000.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12032100.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12032200.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12032300.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12040000.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12040600.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12041200.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12041800.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12050000.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12050600.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12051200.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12051800.shp', 'C:\\ndfd\\degrib\\output\\conus\\WWA_12060000.shp']

 

 

 

 

 

 

 

 

 

 

 

out_location
'E:\\ArcGIS\\Projects\\del_testingMDR\\wwa_Import.gdb'

 

 

 

 

 

 

Tags (1)
0 Kudos
4 Replies
DanPatterson
MVP Esteemed Contributor

doesn't work... does that mean there is nothing in the gdb when you refresh and check its contents? or that you got an error in pycharm?


... sort of retired...
0 Kudos
GabrielMarcus1
Frequent Contributor
Yes when executing it from pyCharm, there's nothing in the GDB.
There were no errors in pyCharm though.
0 Kudos
DanPatterson
MVP Esteemed Contributor

is the part of the script you are using missing the lines where you run the def?


... sort of retired...
0 Kudos
GabrielMarcus1
Frequent Contributor

yes. It 's below.  I was hoping there was something that you would see that I missed. 

 

AddSHPtoGDB("wwa")

 

0 Kudos