Complex file reading

Hi guys,
I’m a WM newbie and I’m trying to read a plain text file from a flow.
The file is structured in the following way, where each line starts with and identifier of the row content.

ex.

ID1 = personal data
ID2 = address data
ID3 = other generic data

The file obviously contains several rows, and ID2, ID3 are optional.

ID1
ID2
ID3
ID1
ID2
ID1
ID2

I’d like to build a list of output file.
Is this possible via the standard WM flow? I’ve tried different options but can’t figure out how to read more file line in a loop or skip loop cycle…

Thanks everybody
Fangar

After some tests I’ve discovered that loading the file as a String would imply to cache the file in a single String.
Then I could:

  1. divide every ID1 occurrence the file in a list of String
  2. substring each item in the list every ID1.ID2.ID3 occurrence

How much overhead would this imply?
Are any other possible solutions?
How about possible collisions between IDX and chars inside the file?

Thank everybody

I would recommend that you create a file schema which defines each record type in the file. You can then use the pub.flatFile.convertToValues service in a loop to iterate through the *ffdata file stream/bytes. This will automatically parse out the input structure into the records and fields as defined in the schema.

Kishore

Amazing! Thanks a lot, I didn’t even know that package!
I’ll made some experiments!
Thank you again.

You create the file schema from developer (New->File Schema) and then define the record types and field layout for each record.

good luck.

Kishore

I’m facing some trouble with the flat file stuff.
I’ve created the schema as follows:

  • ID1 (record)
    • f1 (field)
    • f2 (field)
    • f3 (field)
  • ID2
    • f4
      … etc…

Now the program return the following error; the second line of the input file is not recognized, error code 11, Unrecognized record.

Do you have any clue?

thanks
F.
[/list]

ops… I was using the fixed length format, while the file was a bunch of records in different rows separated by crlf… I’ve changed the type to delimited and it works!