Joining a text file to a Feature Class

326
3
06-19-2012 11:20 PM
Highlighted
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
Reply
0 Kudos
3 Replies
Highlighted
MVP Frequent 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.
Reply
0 Kudos
Highlighted
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 🙂
Reply
0 Kudos
Highlighted
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");
Reply
0 Kudos