Page 1 of 1

Convert fields from text files to CSV

Posted: Thu Feb 07, 2013 6:51 am
by ptr727
Hi

I need to process text files created by an automation process.
The text files have a fixed format, and I need to convert sections of each file into fields in a CSV file.
Where each text file will be a new line in the CSV file.

E.g. [row 6 : 0 to 12], [row 6 : 14 to 20], [row 10 : 14 to 20], etc.

I'd also like to trim any whitespace around any of the resulting fields before inserting into CSV file.

I looked at the docs and samples but could not find a way or wizard to extract fixed location fields into a CSV file.

Any advice?

P.

Re: Convert fields from text files to CSV

Posted: Fri Feb 08, 2013 8:02 am
by DataMystic Support
Hi Pieter,

Using your example, an EasyPattern like this:

Code: Select all

[ 5 (0+ lineChar, crlf),  ;first 5 lines
  capture(13 chars) as 'field1', ' ',
  capture(7 chars) as 'field2', 0+ lineChar, crlf,
  2 (0+ lineChar, crlf),  ;lines 7-9
  13 chars, capture( 7 chars ) as 'field3' ]
And replace with:

Code: Select all

"@field1@","@field2@","@field3@"


Re: Convert fields from text files to CSV

Posted: Fri Feb 08, 2013 8:45 am
by ptr727
Thx