To copy a CSV file in Ruby, you can use the FileUtils
module's cp
method which is provided by the Ruby Standard Library.
main.rb77 chars4 lines
In the above code snippet, we require the fileutils
library and call its cp
method, passing the source file path as the first argument and the destination file path as the second argument. This copies the contents of the source file to the destination file.
Note: If the destination file already exists, it will be overwritten by this method. If you want to avoid overwriting it, you can use cp_r
method instead of cp
.
gistlibby LogSnag