• Stars
  • Rank 1,662,279 (Top 36 %)
  • Language
  • License
    GNU Lesser Genera...
  • Created almost 4 years ago
  • Updated over 1 year ago


There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

R COBOL DI (Data Integration) Package : Import COBOL CopyBook data files directly into R as properly structured data frames.

R COBOL DI (Data Integration) Package: A package for importing COBOL CopyBook data directly into the R Project as data frames.

License LinkedIn Twitter GitHub Email Coherent Logic Limited

The RCOBOLDI Package (COBOL Data Integration Package for the R Project for Statistical Computing) is an R package that facilitates the importation of COBOL CopyBook data directly into R as properly structured data frames.

Note that not all copybook files can be converted into CSV -- for example single-record type files can be converted to CSV however complicated multi-record type files will NOT map to CSV.

R COBOL Data Integration (RCOBOLDI) package examples

Example One: Install the RCOBOLDI package locally and then convert COBOL data files into data frames.

In this simple example the R COBOL Data Integration package has been installed locally and several data files are converted into data frames using the ReadCopyBookAsDataFrame function; the CobolToCSV function is also demonstrated.

This example also how includes a call to CobolToCSV.

R COBOL Data Integration (RCOBOLDI) package preconditions

The following should be executed prior to attempting to run the R script, below.

If you have trouble with rJava and Java 11 then you might need to execute the following:

R CMD javareconf

R COBOL Data Integration (RCOBOLDI) package example

The following example should work with the only change needed being the path to the files.

Test files can be found here.



# The following should work for Mac OSX (El Capitan) and on Linux.

# Or install via source (for Windows users, specifically).
install.packages("RCOBOLDI", type = "source")


# Substitute the directory path below with one which points to the test files being used.
# The test files below can be found here:
# https://github.com/thospfuller/rcoboldi/tree/master/java/rcoboldi-core/src/test/resources 
result <- RCOBOLDI::ReadCopyBookAsDataFrame(".../rcoboldi/java/rcoboldi-core/src/test/resources/example1/DTAR020.cbl", "/Users/thospfuller/development/projects/rcoboldi/java/rcoboldi-core/src/test/resources/example1/DTAR020.bin", "Fixed Length Binary", "cp037")
result <- RCOBOLDI::ReadCopyBookAsDataFrame(".../rcoboldi/java/rcoboldi-core/src/test/resources/example2/DTAR107.cbl", "/Users/thospfuller/development/projects/rcoboldi/java/rcoboldi-core/src/test/resources/example2/DTAR107.bin", "Fixed Length Binary", "cp037")
result <- RCOBOLDI::ReadCopyBookAsDataFrame(".../rcoboldi/java/rcoboldi-core/src/test/resources/example3/AmsLocation.cbl", "/Users/thospfuller/development/projects/rcoboldi/java/rcoboldi-core/src/test/resources/example3/Ams_LocDownload_20041228.txt", "Text", "cp1252")
cobrix_test1_result <- RCOBOLDI::ReadCopyBookAsDataFrame(".../rcoboldi-gh/rcoboldi/java/rcoboldi-core/src/test/resources/example4/absaoss_cobrix_test1_copybook.cob", "/Users/thospfuller/development/projects/rcoboldi-gh/rcoboldi/java/rcoboldi-core/src/test/resources/example4/absaoss_cobrix_test1_example.bin", "**TBD**", "**TBD**")
result <- RCOBOLDI::ReadCopyBookAsDataFrame(".../rcoboldi-gh/rcoboldi/java/rcoboldi-core/src/test/resources/example4/absaoss_cobrix_test1_copybook.cob", "/Users/thospfuller/development/projects/rcoboldi-gh/rcoboldi/java/rcoboldi-core/src/test/resources/example4/absaoss_cobrix_test1_example.bin", "Fixed Length Binary", "cp037")

# The following line will convert the absaoss_cobrix_test1 data file into a CSV file.
RCOBOLDI::CobolToCSV("-I .../rcoboldi/java/rcoboldi-core/src/test/resources/example4/absaoss_cobrix_test1_example.bin -C .../rcoboldi/java/rcoboldi-core/src/test/resources/example4/absaoss_cobrix_test1_copybook.cob -FS Fixed_Length -IC cp037 -O .../temp/absaoss_cobrix_test1.csv")

R COBOL Data Integration (RCOBOLDI) package example output

An example of the R COBOL DI (Data Integration) Package in use.

Try the R COBOL Data Integration (RCOBOLDI) package via a browser using a preconfigured Docker image available on DockerHub

Below we include two examples for working with images in Docker along with a demonstration video showing the package in action. If you just want to try the package on some test data, start here.

Using the R COBOL Data Integration (RCOBOLDI) package RStudio image on DockerHub

The RCOBOLDI Rocker/RStudio image is available on DockerHub. This image is built using dependencies which have been deployed in the thospfuller/drat repository.

The RCOBOLDI Rocker/Verse image is a complete build using source code cloned from the GitHub project repository.

The following is a fully working example based on the Rocker/RStudio image.

Pull and run the R COBOL Data Integration (RCOBOLDI) DockerHub image from the command line

docker pull thospfuller/rcoboldi-rockstar-rstudio:[latest or 1.0.3 or some other tag]


docker image ls

should show something like this:

> REPOSITORY                            TAG                 IMAGE ID            CREATED             SIZE
> thospfuller/rcoboldi-rockstar-rstudio   1.0.3             3f8c1c269940        37 minutes ago      2.42GB


docker run -d -p 8787:8787 -e PASSWORD=password --name rstudio -i -t 3f8c1c269940

Try the R COBOL Data Integration (RCOBOLDI) package from the browser

The next is to test this in R so point your browser to http://localhost:8787 and use "rstudio" and "password" to login and then execute the following:

result <- RCOBOLDI::ReadCopyBookAsDataFrame("/home/rstudio/rcoboldi/java/rcoboldi-core/src/test/resources/example1/DTAR020.cbl", "/home/rstudio/rcoboldi/java/rcoboldi-core/src/test/resources/example1/DTAR020.bin", "Fixed Length Binary", "cp037")

Building the R COBOL Data Integration (RCOBOLDI) RStudio Docker Image Locally

Step 1.) Build the R COBOL Data Integration (RCOBOLDI) (this can take up to 20 minutes).

docker build -t rcoboldi/rocker-rstudio:1.0.1 https://raw.githubusercontent.com/thospfuller/rcoboldi/master/docker/rocker/rstudio/Dockerfile
[some image id]

Build the Docker image from the R COBOL Data Integration package Dockerfile."

Step 2.) Run the R COBOL Data Integration (RCOBOLDI) container based on the image created in the previous step

docker run -d -p 8787:8787 -e PASSWORD=password --name rstudio -i -t [some image id]
[some container id]

Step 3.) Browse to http://localhost:8787 and enter the username & password combination rstudio & password.

The next three steps appear in the video.

Steps 4-7.) From the R CLI execute:

#### Step 4.)

#### Step 5.)

#### Step 6.)
result <- RCOBOLDI::ReadCopyBookAsDataFrame("DTAR020.cbl", "DTAR020.bin", "Fixed Length Binary", "cp037")

#### Step 7.)

An example of the R COBOL Data Integration Package loading a file with the inputFileStructure set to "Fixed Length Binary" and the font set to "cp037". This should work out-of-the-box with a container built from the rcoboldi:rocker-rstudio image."


If you're looking to load COBOL data files into the R Project for Statistical Computing then you came to the right place.

The Dockerfile in this example is based on Rocker / RStudio and will be running locally on port 8787.

Below is a video which demonstrates the R COBOL Data Integration package running in Docker.

Introduction To RCOBOLDI Data Integration Package

See Also

R COBOL Data Integration (RCOBOLDI) package logging

The Java API uses Log4J and writes files to the ~/rcoboldi-package-logs/ directory. The Log4J configuration file can be found here.

See Also