Skip to main content

I am having 100 individual text files consist of Point feature..So..........At a time, How could i convert each files into KML files respectively? 

Multiple ways to do this. How I would do it:

  • Creator to initiate process.
  • FeatureReader (directory and files) to find all files in the input directory.
  • FeatureReader (text?) to read the files. Not sure what you have if you say text files with points.
  • Something to create geometry from the text file. Maybe a VertexCreator or a GeometryReplacer.
  • FeatureWriter to write the features to KML.

 Sorry….I  couldn't able to execute the process .

I have attached snap of 3 files .

Please explain How could i do it for the folder contains 100 files with one shot.
Like showing below .I want the result.

 

INPUT                       OUTPUT
3_631_0_1_001.txt       3_631_0_1_001.kml
3_631_0_1_002.txt       3_631_0_1_002.kml
3_631_0_1_003.txt       3_631_0_1_003.kml
. .
. .

So...on...                     So...on...
.
.
3_631_0_1_100.txt       3_631_0_1_100.kml


Can either manually select the Files or read the list using a File/Folder Reader to output the list to a FeatureReader as @nielsgerrits suggests.

 

The concepts to learn though are:

  1. Reading the Input file path as a separate metadata attribute for all Features read to the Workspace
  2. Writing using “Fan Out” where the Writer will send each Feature to different Files depending on a separate “Output File Path” attribute

First setup a Multiple File TXT Reader that outputs all Features into a Single Merged Feature Type.  This is a manually set TXT Reader below, but the steps are similar to FeatureReader if send a File Name Features output from say a File Reader upstream of it.

But simple case first for the concept using a hard coded list of files in a TXT Reader

 

Go into the Reader settings and Expose fme_basename and fme_dataset for the Features.  This is the Input file name without extension, and the Input file path respectively


Then use something like AttributeCreator , StringReplacer to set the Output File Path for every feature.  In this example, just setting OutputFilePath to =  Input File Path but with “.TXT” replaced with “.KML”, but can use any combination of Transformers to make the file names, paths, KML names etc. to whatever wish.

 

​Can then use FeatureWriter to “Fan Out” the Features the individual KML File Paths.  In this case we can also optionally reuse fme_basename to provide the Name for inside KML object/block

Similar can be done with a dedicated KML Writer: The Parameters are a little more advanced in a KML Writer but not quite as intuitive to learn.

 





….now the more advanced case for dynamically reading a File List involves a more complicated, but not very hard step of using a File/Folder Reader

In this case I’m going to set a File Pattern Filter of “new*.txt” to only take the files I want
 


This ends up with this, in this case, there are 53 TXT files in C:\Temp that match that File Path Filter Pattern.


Can send that list of Features to a FeatureReader
 

 

Set the Dataset to Read as the upstream File Name Feature Windows Path.  In this case FeatureReader will execute 53 times, once for every triggering input Feature

 

Similarly want all 53 executions to output to a single Combined Feature Port

 

...and similarly Expose fme_basename and fme_dataset to the Workspace

Because it is a dynamic form of Reader, then also need to tell it to read fme_basename, fme_dataset ,fme_feature_typetext_line_data attributes as well, since in a multiple file reader situation it does not know the Source Schema until we give it a sample file to check with “Import”

 


Thank you for the solution! I implemented the solution, and it worked perfectly for my data conversion.

I appreciate your help.

Thank you so much for your time 😊


Reply