How to read flat file using the filelayout with each line having different layout

When all the lines in the data have more than one file layout structure, it is difficult to read them and load them to different record. Record file ID can be used to simplify the task but it will work only when the one file record ID to one record mapping is present. If the file has the values where more than one file record ID needs to be mapped to one record.

When file type is fixed file.
There is one way to do a work around in which one record and one file layout will created on this record in which all the fields from all the different records in to which data needs to be loaded. In record should have all the fields as character fields later convert it in to number and date.
In the file layout define start position and end position of fields based on the layout that this field belongs to i,e more than one field will have the same position and position may be overlapping as well. This will work when the common fields in the different records in to which we need to load should have same position in the file.

In the Peoplecode after read rowset use the custom sql based on the field to identify the record that needs to be populated execute insert sql.

When file is not the fixed file.
Then read all the data in to one field of record. field length should be long enough to load the entire line of the data. Split the data based on the seperator character. Identify the record in to which data needs to be loaded based on the certain field and insert data in to that table.