CSV File Reader

  • Share this:

Code introduction


This function reads a CSV file at the specified path and returns the data in the form of a list.


Technology Stack : csv

Code Type : Function

Code Difficulty :


                
                    
import csv
import datetime
import os
import re
import sys

def read_csv_file(file_path):
    """
    读取CSV文件并返回数据
    """
    data = []
    with open(file_path, mode='r', encoding='utf-8') as file:
        csv_reader = csv.reader(file)
        for row in csv_reader:
            data.append(row)
    return data                
              
Tags: