wsp-sag / tcadr

A library to read/write TransCAD binary files in R.
Other
9 stars 7 forks source link

File name restriction #19

Closed sudhakar-atturu closed 6 years ago

sudhakar-atturu commented 6 years ago

When the input BIN file name consists a string 'mbin' it gets replaced with '.DCB'. I tried to read combinedTrips.bin file using read_tcad function, but the tcadr reads this file name as 'co.DCBedTrips.bin'. Here is the error messages.

Error in file(con, "r") : cannot open the connection In addition: Warning message: In file(con, "r") : cannot open file '../scenarios/calibration_run/outputs/visitor_model/co.DCBedTable.DCB': No such file or directory

gregmacfarlane commented 6 years ago

You'll need to fix the regular expression here:

read_tcad <- function(file, strip_whitespace = TRUE){

  # Get file string for the DCB file.
  dcb_file <- gsub(".bin", ".DCB", file)

  # Read binary file attributes from DCB file
  row_length <- as.numeric(
    as.numeric(gsub("[^0-9]", "", readLines(dcb_file, 2)[2]))
  )

Funny!