Count the length (number of lines) of a CSV file?

后端 未结 7 1185
野性不改
野性不改 2020-12-31 02:46

I have a form (Rails) which allows me to load a .csv file using the file_field. In the view:

    <% form_for(:upcsv, :html => {:multipa         


        
7条回答
  •  隐瞒了意图╮
    2020-12-31 03:05

    CSV.foreach(file_path, headers: true).count
    

    Above will exclue header while counting rows

    CSV.read(file_path).count
    

提交回复
热议问题