Topic
  • 2 replies
  • Latest Post - ‏2019-05-21T09:36:10Z by Santanu
Santanu
Santanu
37 Posts

Pinned topic New Line character Mapping

‏2019-05-17T14:01:58Z |

Hi,

I have two csv file ,

1. Have new line character at the end of each record

2. Does not have new line character for last record but it has new line character for other record

so i have create a type tree to read both the file

File--Parent group has Record(0:s) has two item Field1 & Field2

File Implicitly delimited with <NL> location infix

Record (0:s) Explicitly delimited with , and location infix

The above structure reads the 2nd file successfully but giving error for 1st file as "INPUT 1 was valid but contained 2 bytes of unknown data at the end"

I already tried with postfix location on File level and terminator as <NL> on record level but this structure will read first file and failed for  2nd file.

So is it possible to have one structure which can read both the file?

Thanks

Santanu

  • PaulBrett
    PaulBrett
    368 Posts
    ACCEPTED ANSWER

    Re: New Line character Mapping

    ‏2019-05-20T15:21:59Z  

    The attached example seems to work quite well.

    Note that the DataRows group of the 'ReadBoth.mtt' Typetree contains a component rule to ensure that the last <NL> is not treated as data, and the File group as a 2 byte 'garbage' item at the end to collect the final <NL>.

    Thank you.

    Paul

    Follow me on Twitter

    Attachments

    Updated on 2019-05-20T15:22:17Z at 2019-05-20T15:22:17Z by PaulBrett
  • PaulBrett
    PaulBrett
    368 Posts

    Re: New Line character Mapping

    ‏2019-05-20T15:21:59Z  

    The attached example seems to work quite well.

    Note that the DataRows group of the 'ReadBoth.mtt' Typetree contains a component rule to ensure that the last <NL> is not treated as data, and the File group as a 2 byte 'garbage' item at the end to collect the final <NL>.

    Thank you.

    Paul

    Follow me on Twitter

    Attachments

    Updated on 2019-05-20T15:22:17Z at 2019-05-20T15:22:17Z by PaulBrett
  • Santanu
    Santanu
    37 Posts

    Re: New Line character Mapping

    ‏2019-05-21T09:36:10Z  
    • PaulBrett
    • ‏2019-05-20T15:21:59Z

    The attached example seems to work quite well.

    Note that the DataRows group of the 'ReadBoth.mtt' Typetree contains a component rule to ensure that the last <NL> is not treated as data, and the File group as a 2 byte 'garbage' item at the end to collect the final <NL>.

    Thank you.

    Paul

    Follow me on Twitter

    Thanks for your time

     

    Thanks

    Santanu