Convert from Rio Package fills in cells with ..1.., ..2..

I have the below code (I removed some business specific information). I am trying to convert a xlsx file to a csv file using CONVERT, but it tries to put the first row as a header which it is not and it putting numbers in for the headers. Is there a way that I can convert without those numbers coming in as my headers?

cat("\n", format(Sys.time(), "%a %m/%d/%Y %X"), ": Loading libraries and functions... ")
source("R:\LPSEC\STGY\R\DL_FraudOps_Functions.R")
library(tidyverse)
library(rio)

TOM_Dir <- "R:\LPSEC\RPRT\TOM_Output\"

dataFolder <- paste(Sys.getenv("TEMP"), "\FSB", sep = "")

fileExtn <- "^[^~]+(*\.xlsx)$"

dataFileList1 <- list.files(path = dataFolder,
pattern = fileExtn,
full.names = TRUE,
recursive = FALSE,
ignore.case = TRUE)

dataFileDate2 <- format(Sys.time(), "%Y%m%d%H%M%S")

dataFile2 <- paste0("ScamFile_", dataFileDate2)

cat("done.")

if (length(dataFileList1) <=0) {

cat("\n", format(Sys.time(), "%a %m/%d/%Y %X"), ": Notifying users about no data to review... ")

if (hour(Sys.time()) < 9){
  # SendMail(outFile = "", ToEmail = "Card_Fraud@santander.us; EDWILUSA@santander.us; ",
  SendMail(outFile = "", ToEmail = "karen.batykefer@santander.us; ",

} else {

  SendMail(outFile = "", ToEmail = "karen.batykefer@santander.us; ",

cat("done.")

} else {
cat("\n", format(Sys.time(), "%a %m/%d/%Y %X"), ": Setting variables and constants... ")

tmpDirFolder <- paste0(Sys.getenv("TEMP"), "\\SCM\\")
reviewedFolder <- paste0("

if(dir.exists(tmpDirFolder) == TRUE){
  unlink( paste0(Sys.getenv("TEMP"), "\\SCM"), recursive = TRUE)
}

dir.create(path = tmpDirFolder)

cat("\n", format(Sys.time(), "%a %m/%d/%Y %X"), ": Copying data file(s) to ", tmpDirFolder, "... ")
  file.copy(from = dataFileList1,
            to = tmpDirFolder,
            overwrite = T,
            copy.date = T,
            copy.mode = T)
cat("done.")


cat("\n", format(Sys.time(), "%a %m/%d/%Y %X"), ": Copying data file(s) to ", reviewedFolder, "... ")
  file.copy(from = list.files(path = tmpDirFolder,
                              pattern = fileExtn,
                              full.names = TRUE,
                              recursive = FALSE,
                              ignore.case = TRUE),
                              to = reviewedFolder,
                              overwrite = T,
                              copy.date = T,
                              copy.mode = T)
cat("done.")

cat("\n", format(Sys.time(), "%a %m/%d/%Y %X"), ": Copying and rename files... ")
  dataFileList <- list.files(path = tmpDirFolder,
                             pattern = fileExtn,
                             full.names = TRUE,
                             recursive = FALSE,
                             ignore.case = TRUE)
  
  dataFileList2 <- paste0(tmpDirFolder,"ScamFile_", 1:length(dataFileList), "_",dataFileDate2,".xlsx")
  
  # dfFiles <- list.files(path = dataFolder, pattern = fileExtn,
  #                       full.names = T, recursive = FALSE,
  #                       ignore.case = TRUE)
  
  file.copy(from = dataFileList, to = dataFileList2)
  
  file.remove(dataFileList)

  # df <- setNames(lapply(dataFileList, read_excel), dfFiles)
  # df <- bind_rows(df, .id = "Batch")
cat("done.")

cat("\n", format(Sys.time(), "%a %m/%d/%Y %X"), ": Prepping TOM file... ")
  
  csvfile <- mapply(convert, dataFileList2, gsub("xlsx", "csv", dataFileList2), )
  
  unlink(dataFileList2)
  
  csvFileList <- list.files(path = tmpDirFolder,
                             pattern = "^[^~]+(*\\.csv)$",
                             full.names = TRUE,
                             recursive = FALSE,
                             ignore.case = TRUE)
  
  file.copy(from = csvFileList,
            to = TOM_Dir,
            overwrite = T,
            copy.date = T,
            copy.mode = T)

cat("done.")

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.