Comments (4)
@yruslan can you please provide your thoughts on this. Thanks!
from cobrix.
Yes, it is possible to use Cobrix specifying more than one copybook using:
.option("copybooks", "/path/to/copybook1,/path/to/copybook2,/path/to/copybook3")
This will create a layout where root GROUPs redefine each other for each copybook.
For example, if copybooks are:
val copyBookContents1: String =
""" 01 RECORD-COPYBOOK-1.
| 05 GROUP-1.
| 06 FIELD-1 PIC X(10).
| 06 FILLER PIC X(5).
| 06 GROUP-2.
| 10 NESTED-FIELD-1 PIC 9(10).
| 10 FILLER PIC 9(5).
|""".stripMargin
val copyBookContents2: String =
""" 01 RECORD-COPYBOOK-2A.
| 05 GROUP-1.
| 06 FIELD-1 PIC X(20).
| 06 FILLER PIC X(10).
| 06 GROUP-2.
| 10 NESTED-FIELD-1 PIC 9(20).
| 10 FILLER PIC 9(10).
| 01 RECORD-COPYBOOK-2B REDEFINES RECORD-COPYBOOK-2A.
| 05 GROUP-1.
| 06 FIELD-1 PIC X(20).
| 06 FILLER PIC X(10).
| 06 GROUP-2.
| 10 NESTED-FIELD-1 PIC 9(20).
| 10 FILLER PIC 9(10).
|""".stripMargin
val copyBookContents3: String =
""" 01 RECORD-COPYBOOK-3.
| 05 GROUP-1.
| 06 FIELD-1 PIC X(30).
| 06 FILLER PIC X(15).
| 06 GROUP-2.
| 10 NESTED-FIELD-1 PIC 9(30).
| 10 FILLER PIC 9(15).
|""".stripMargin
The merged copybook layout will be:
-------- FIELD LEVEL/NAME --------- --ATTRIBS-- FLD START END LENGTH
1 RECORD_COPYBOOK_1 r 1 1 90 90
5 GROUP_1 2 1 30 30
6 FIELD_1 3 1 10 10
6 FILLER 4 11 15 5
6 GROUP_2 5 16 30 15
10 NESTED_FIELD_1 6 16 25 10
10 FILLER 7 26 30 5
1 RECORD_COPYBOOK_2A rR 8 1 90 90
5 GROUP_1 9 1 60 60
6 FIELD_1 10 1 20 20
6 FILLER 11 21 30 10
6 GROUP_2 12 31 60 30
10 NESTED_FIELD_1 13 31 50 20
10 FILLER 14 51 60 10
1 RECORD_COPYBOOK_2B rR 15 1 90 90
5 GROUP_1 16 1 60 60
6 FIELD_1 17 1 20 20
6 FILLER 18 21 30 10
6 GROUP_2 19 31 60 30
10 NESTED_FIELD_1 20 31 50 20
10 FILLER 21 51 60 10
1 RECORD_COPYBOOK_3 R 22 1 90 90
5 GROUP_1 23 1 90 90
6 FIELD_1 24 1 30 30
6 FILLER 25 31 45 15
6 GROUP_2 26 46 90 45
10 NESTED_FIELD_1 27 46 75 30
10 FILLER 28 76 90 15
I usually prefer to combine copybooks manually so I have more control on which fields are part of every segment, and which are different for each segment.
from cobrix.
@yruslan Thanks for your reply. In my case there are multiple record types defined in single copybook. So, do you think this ".option("copybooks", "/path/to/copybook1,/path/to/copybook2,/path/to/copybook3")" works?
from cobrix.
The "copybooks" options is specifically designed for the situation of multiple record types. And it works for our use cases.
from cobrix.
Related Issues (20)
- Add support for parsing copybooks given Spark options
- Missing SIgn for few fileds that are negative HOT 5
- How to read a pipe separated file with Cobrix HOT 3
- PIC S9(10)V USAGE COMP-3 is converted to long instead of Decimal(10,0) HOT 7
- comp-3 values parsing issues HOT 2
- Shade ANTLR runtime in the parser to avoid ANTLR potential incompatibility issues
- Under some circumstances Cobrix selects wrong record reader failing the Spark job
- Add a feature to collapse structs or the output data
- Add support for `_` for key generation
- DataFrame with some columns in EBCDIC HOT 1
- How to read a EBCDIC file with multiple columns HOT 30
- Metadata copying method does not retain existing metadata HOT 3
- EBCDIC to ASCII file conversion HOT 2
- Add support for COMP-3 numbers without the sign nibble HOT 20
- java.lang.AssertionError: assertion failed: Byte array does not have correct length HOT 14
- Add maximum length metadata for 'seg_id0', ... fields
- Add EBCDIC writer HOT 1
- Blank fields are not recognized. HOT 3
- Spaces getting trimmed in Cobrix HOT 3
- Does Cobrix provide a way to convert Text File to EBCDIC Binary fromat Conversion HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cobrix.