Import CSV files based on Field Name in Feature Dataset

206
5
Jump to solution
2 weeks ago
Paul_Duffy_Waters_of_LIFE
New Contributor II

Hi, 

I have a Feature Class which shows the extent of a number of associated CSV files containing DTM points. Using a select by location query, I have created a second feature class which contains a subset of those CSV files I want to import to a GDB.

My question is, is there a way to import CSV files based on the field name in the feature class so I only import those CSV files?

Thanks,

Paul

 

Table.JPG

Explorer.JPG

 

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
Paul_Duffy_Waters_of_LIFE
New Contributor II

I ended up doing this in a roundabout fashion as I hadn't received the above suggestions in time.

I used the selection from the Feature Class to create a text file containing a list of the files I wanted called "PullFiles.txt"

I created a new folder called "HSO_WB_Files" and used PowerShell to copy the relevant files to that folder using the below script found online:

Paul_Duffy_Waters_of_LIFE_0-1713425071621.png

I batch imported all the CSV files into a GDB.

I then used a Model to Iterate through all the files and create XY point files from each

Paul_Duffy_Waters_of_LIFE_1-1713425401068.png

The suggestions by Bob and Dale are more elegant, but this worked anyway.

 

 

View solution in original post

5 Replies
BobBooth1
Esri Contributor

You could make a list of the table names and use Python to iterate over the list and add the tables to the map.

https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/table.htm#:~:text=script%20will%20add%20a%20t...

Paul_Duffy_Waters_of_LIFE
New Contributor II

Thanks Bob, thats' a good solution

0 Kudos
Dale_Honeycutt
Occasional Contributor II

Another way to do this is within ModelBuilder.  ModelBuilder has the Iterate Row Selection and Iterate Field Value  iterator which you could use to grab the value of the CSV REF field into a model variable.  You could then use inline substitution with this model variable to construct the pathname to the CSV file, then feed that pathname into the Table To Table tool to create a .gdb table.

This topic explains all the iterators available to you.

Paul_Duffy_Waters_of_LIFE
New Contributor II

Thanks Dale, that would work alright!

0 Kudos
Paul_Duffy_Waters_of_LIFE
New Contributor II

I ended up doing this in a roundabout fashion as I hadn't received the above suggestions in time.

I used the selection from the Feature Class to create a text file containing a list of the files I wanted called "PullFiles.txt"

I created a new folder called "HSO_WB_Files" and used PowerShell to copy the relevant files to that folder using the below script found online:

Paul_Duffy_Waters_of_LIFE_0-1713425071621.png

I batch imported all the CSV files into a GDB.

I then used a Model to Iterate through all the files and create XY point files from each

Paul_Duffy_Waters_of_LIFE_1-1713425401068.png

The suggestions by Bob and Dale are more elegant, but this worked anyway.