You can use the built-in csv
module and os
module to achieve this. Here's an example code snippet:
main.py398 chars14 lines
This code iterates through all the files in the directory specified by folder_path
. For each file that ends with the .csv
extension, it opens the file using csv.reader()
. The code then prints the filename and each row in the CSV file to the screen. The newline=""
argument in our open()
function is used to ensure that the CSV file is read correctly.
gistlibby LogSnag