Import .CSV to Geodatabase with Python

6303
7
07-29-2016 08:35 AM
ModernElectric
Occasional Contributor III


I really have no idea what I am doing wrong. I can create a Data Model in ArcMap/ArcCatalog and run the TableToTable tool to import a .CSV file into an existing File Geodatabase without any problems. However, when I run the same tool in a Python Script, it comes back saying the file (.CSV) is not supported. According the ArcMap 10.2 help, a .TXT and .CSV file format is supported. Is there another module that I am not importing? What piece am I missing here? I am want to build a tool that will import a bunch of .CSV file(s) into my working geodatabase on a as needed basis which will be used for other processes, but this first step is preventing future development.

Thank You in advance

0 Kudos
7 Replies
ChristianWells
Esri Contributor

What version of software are you running? Are you using background GP? Are you running this inside ArcMap or in IDLE or some other IDE?

0 Kudos
ModernElectric
Occasional Contributor III

I am currently running ArcGIS 10.2.2 and would like to run a script through IDLE. I have around (12) different .TXT files of parcel data that is produced on a weekly basis from the county GIS database and want to be able to import them into a File Geodatabase - geodatabase table. From there, I have a good understanding of what to do from there to incorporate any changes into my working datasets. Its the beginning part that I am having issues with. Instead of doing table by table by hand, would like a Python script to do this for me automatically.

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

Darren Wiens​ posted an answer on a similar thread and thought this might work http://www.arcgis.com/home/item.html?id=f3d91b8f852042e289e09a7ec8342431 but there was no report back

0 Kudos
ModernElectric
Occasional Contributor III

Dan:

   Thank you for that. I actually just found that after doing a google search. I'm still trying to learn the complex world of Python scripting and takings different bits of script and putting them together. The way the script is written is set to run in ArcMap or ArcCatalog. How would I modify the script to run specifically in IDLE since the script is designed to run from Arc Toolbox with the user adding in text parameters? There would be about (12) different file(s) that all would go into the same File Geodatabase and result in (12) new geodatabase tables.

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

That is the point, the tool must be run from within arcmap... it handles the fluff stuff.  If you want a pure python implementation, there is the csv module and a few others (if you have the anaconda distribution).  I would run it from arcmap, get the immediate job done, then worry about perfecting the work environment or rewriting to suit your needs for a later time.

0 Kudos
ModernElectric
Occasional Contributor III

Sounds good. I will mess around with some different workflows and see what works the best.

Thank You

0 Kudos
RebeccaStrauch__GISP
MVP Esteemed Contributor

Have you looked at the scripting samples in the 10.2.x help?

They should be able to be run in idle, but you will need to "import arcpy" module, and you  may still need to checkout a desktop license.  If so, check out the help with script samples for setting the license ArcGIS Help (10.2, 10.2.1, and 10.2.2)   If you are using the IDLE as you IDE from within Map/Catalog, it should already have the license checked out.

0 Kudos