To find the extension of a csv file in Ruby, you can make use of the File.extname
method which returns the extension (including the dot .
) of a file path. Here's how you can use it:
main.rb218 chars6 lines
Alternatively, you can also use regular expressions to match the extension of the file path:
main.rb97 chars3 lines
Both of these methods should give you the file extension of your CSV file in Ruby.
gistlibby LogSnag