Joining a text file to a Feature Class

761
3
06-19-2012 11:20 PM
Almuatasim_Ahmed_SaidAl-Hinai
New Contributor
Hi All,

Is there any way using Arcobjects where I can join a text file to a feature class using a common id filed so all the attributes on the text file are copied to their corresponding fields on the Feature Class? I will highly appreciate if any code example can be provided. We are getting data from different sources and some of these data are in text file format which we need to batch copy to their corresponding feature classes.

Thanks a lot

AlHinai
0 Kudos
3 Replies
DuncanHornby
MVP Notable Contributor
Personally I would convert the text files to dBase or better still a GeoDatabase Table as then your data is in a Table which will make joining easier.
0 Kudos
Almuatasim_Ahmed_SaidAl-Hinai
New Contributor
Personally I would convert the text files to dBase or better still a GeoDatabase Table as then your data is in a Table which will make joining easier.


Thanks Hornbydd for reply. Yes you are right but I asked to join text files to FC  only because we want to build an application to batch join text files that we are having to their related Feature classes. Yes another way might be build a routine to convert these text files to Dbase format and then batch joining them to their related feature classes. It will be good if someone can assist us in applying the later concept 🙂
0 Kudos
JohnHauck
Occasional Contributor II
See the TextFileWorkspaceFactory coclass.

Small code example taken from the assemblies overview:

// Create a text file workspace factory.
Type factoryType = Type.GetTypeFromProgID(
    "esriDataSourcesOleDB.TextFileWorkspaceFactory");
IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance
    (factoryType);

// Open a directory of CSV files using its path.
IWorkspace workspace = workspaceFactory.OpenFromFile(@"C:\Data\CSV", 0);

// Open a CSV file as a table.
IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;
ITable table = featureWorkspace.OpenTable("Levee.csv");
0 Kudos