Skip to main content

Hi there,

I've started to play around with the CAT (column aligned text) reader. Is there a way to specify column definition using another text or csv file instead of hardcoding it in the reader?

Any advice would be good.

Thanks,

W

You can't dynamically set the column widths on the CAT reader. I think the best FME can offer is the TextLine Reader followed by the AttributeSplitter. To make that 'dynamic' you could try using a scripted parameter to set the AttributeSplitter's format string.


You can't dynamically set the column widths on the CAT reader. I think the best FME can offer is the TextLine Reader followed by the AttributeSplitter. To make that 'dynamic' you could try using a scripted parameter to set the AttributeSplitter's format string.

Excellent @MarkAtSafe

 


Hi @generationn00b Can you please post a suggestion at https://knowledge.safe.com/content/idea/list.html about setting the CAT reader's schema with another file? I've seen this idea before.


Hi @generationn00b Can you please post a suggestion at https://knowledge.safe.com/content/idea/list.html about setting the CAT reader's schema with another file? I've seen this idea before.

Posted. See

 

https://knowledge.safe.com/idea/71574/dynamically-set-the-column-definition-for-column-a.html?

You can't dynamically set the column widths on the CAT reader. I think the best FME can offer is the TextLine Reader followed by the AttributeSplitter. To make that 'dynamic' you could try using a scripted parameter to set the AttributeSplitter's format string.

Thanks. I ended up using Pythoncreator but might investigate using scripted params as well..

A possible workaround (or a hack ?) in the current version of FME is: use a FeatureReader to read a CAT file and create a published parameter linking to the schema parameter in the FeatureReader (CAT reader).

0684Q00000ArLplQAF.png

Then, you can set a schema through the published parameter with this syntax.

<field name>,<field type>,<column width> ,<field name>,<field type>,<column width>]*

e.g.

field1,Integer,5,field2,String,20,field3,String,15

See the parameters dialog of the CAT reader to learn possible field types.

Also you can run the workspace through a WorkspaceRunner within another workspace. In the case, you can set the schema through a feature attribute.

0684Q00000ArLusQAF.png


A possible workaround (or a hack ?) in the current version of FME is: use a FeatureReader to read a CAT file and create a published parameter linking to the schema parameter in the FeatureReader (CAT reader).

0684Q00000ArLplQAF.png

Then, you can set a schema through the published parameter with this syntax.

<field name>,<field type>,<column width> ,<field name>,<field type>,<column width>]*

e.g.

field1,Integer,5,field2,String,20,field3,String,15

See the parameters dialog of the CAT reader to learn possible field types.

Also you can run the workspace through a WorkspaceRunner within another workspace. In the case, you can set the schema through a feature attribute.

0684Q00000ArLusQAF.png

Just tested this with FME 2018 and it works like a charm.  Thank you!!

 

 


A possible workaround (or a hack ?) in the current version of FME is: use a FeatureReader to read a CAT file and create a published parameter linking to the schema parameter in the FeatureReader (CAT reader).

0684Q00000ArLplQAF.png

Then, you can set a schema through the published parameter with this syntax.

<field name>,<field type>,<column width> ,<field name>,<field type>,<column width>]*

e.g.

field1,Integer,5,field2,String,20,field3,String,15

See the parameters dialog of the CAT reader to learn possible field types.

Also you can run the workspace through a WorkspaceRunner within another workspace. In the case, you can set the schema through a feature attribute.

0684Q00000ArLusQAF.png

@generationn00b, @takashi, we are looking to use the same pattern to load CAT datasets.  Your post was very helpful; however, I still could not figure out how and where to "set the schema via parameters".  Do you mind providing a bit more detail or maybe a screenshot?  Thanks!

 

 


Reply