Question

Is there a way to write a tables schema and data type out to a text file?

  • 15 February 2021
  • 3 replies
  • 37 views

Badge +1
Is there a way to write a tables schema and data type out to a text file?

3 replies

Badge +7

I'd use the Schema feature from a FeatureReader, exploding the attribute list and then using name (attribute name) and native_data_type to build a text file? This could be done when reading, or add an extra FeatureReader (Schema feature only) after writing out the data.

Badge +1

thanks Tom. knew there was a way, just couldnt get brain to function!

Will post result for others to use, as this is for metadata population.

 

Badge +1

Creator > Feature Reader > Attribute Manager > Attribute Trimmer > Text file writer

In Feature Reader set Max features to read to 1.

Change Schema\\Data Feature to be Schema Features

Connect output to <Schema>

Attribute Manager - depends on how you want to expose the values - I used multiple lines and built a new atttribute to populate a text file

$(DATASET)

@Value(fme_feature_type_name)

Attribute_Name Datatype

@Value(attribute{0}.name) @Value(attribute{0}.native_data_type)

@Value(attribute{1}.name) @Value(attribute{1}.native_data_type)

@Value(attribute{2}.name) @Value(attribute{2}.native_data_type)

 

You can list as many attributes as you need, I didnt make mine dynamic but am sure you could.

Through in the attribute Trimmer to remove any excess lines and spaces from the end.

Write out using text_Line and fan out on the dataset using @Value(fme_feature_type_name).txt

 

 

Not to hard after all.

Now just to embed into XML metadata.....

Reply