Skip to content

Data error while using given dat file and copy book from this repo #832

@chelika2000

Description

@chelika2000

Data read error: Downloads\COMP.DETAILS.SEP30.DATA.dat that are NOT DIVISIBLE by the RECORD SIZE calculated from the copybook

I am new to Cobrix and trying to explore for my use case: Read Mainframe data using copy book
Question
I am trying to use the data file and copy that presents in this repo.
examples/example_data/companies_data ------------ as the data file
examples/example_data/companies_copybook.cpy --- as the copy book
I am using spark 3.5.8 and using local machine.
Here is my code that I am trying:

spark = get_spark_session()

    # Parse the file using Cobrix
    df = spark.read.format("cobol") \
        .option("copybook", copybook_path) \
        .option("is_record_sequence", "true") \
        .option("is_rdw_big_endian", "true") \
        .option("debug", "true") \
        .load(datafile_path)

    # Show the Schema
    st.subheader("Parsed Copybook Schema:")
    # We extract the schema as a readable tree-like list
    schema_fields = [f"{field.name} ({field.dataType.simpleString()})" for field in df.schema.fields]
    st.write(schema_fields)

    # Show the Data
    st.subheader(f"Data Preview (First {num_rows} records):")

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions