Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed length with arrays? #26

Open
end-user opened this issue Aug 8, 2016 · 1 comment
Open

Fixed length with arrays? #26

end-user opened this issue Aug 8, 2016 · 1 comment

Comments

@end-user
Copy link

end-user commented Aug 8, 2016

I have a situation where I'd like to parse a flat file without linebreaks that also contains "sub" arrays. Is there a way to specify that as a parser definition? (I may not have the right syntax for your PZMAP) For example, if I had a definition like this:

<record name="owner">
    <column  length="5"/>
    <record name="pet" length="5" repeat="3" />
</record>

And a dataset like this (represents 2 records of 20 characters, pipes added for visibility):

|AliceTiny Fluff     Bob  Zap  Frog Wooly|

Would create:

<owner name="Alice">
    <pet>Tiny</pet>
    <pet>Fluff</pet>
</owner>
<owner name="Bob">
    <pet>Zap</pet>
    <pet>Frog</pet>
    <pet>Wooly</pet>
</owner>
@benoitx
Copy link
Contributor

benoitx commented Aug 8, 2016

Hi

I do not know if it is possible but I'd assume not.

A workaround would be to define pet1,pet2 and pet3 in the XML definition and then call those.

Also you could define a Pets subsection with a discriminator. A common type of record could be embedded / different, eg if a record starts with 'X' then the format should be a record X; if it starts with 'Y' then follow the Y record.

I hope this helps

Feel free to submit a patch or pull request if you want to develop this 'repeat' mechanism but I'm not too sure how the getString('xxx') would work and it has to work with CSV and other delimited formats too.

Benoit


Important Notice
This communication contains information that is considered
confidential and may also be privileged. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the
information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender and
delete the original

On 8 Aug 2016, at 17:15, Oblio notifications@github.com wrote:

I have a situation where I'd like to parse a flat file without linebreaks that also contains "sub" arrays. Is there a way to specify that as a parser definition? (I may not have the right syntax for your PZMAP) For example, if I had a definition like this:

And a dataset like this (represents 2 records of 20 characters, pipes added for visibility):

|AliceTiny Fluff Bob Zap Frog Wooly|
Would create:

Tiny Fluff Zap Frog Wooly — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants