0
I have a CSV file with the information as below:
nome;cpf;ano;faculdade;
Pedro Sampaio;45896588963;2010;fmu;
Yuri Martins;45885485896;2012;uninove;
Pablo Vittar;32585296363;2020;unip;
I read this file using the code below, to get only the name "Pedro Sampaio"
require "csv"
path = "importador.csv"
option = { :encoding => "UTF-8", :skip_blanks => true, col_sep: "," }
array_students = CSV.read(path, options)
puts array_students[1][0][0..12]
I tried to use CSV.foreach but I could not reach the result of locating only the name as I did with read, but I know that each person can have a name bigger or smaller than Pedro Sampaio and I’m having difficulty to pick the name and add in a variable.
Maybe I didn’t quite understand your explanation, I’ll put what I did as an answer because size is not allowed here.
– Victor
I updated the response and put a link with the code for you to see how it was done.
– scylo
ah, its form became much simpler, after a conference I managed to reach a solution but with much more code. I will also share here: https://repl.it/@seuvitoo/reader
– Victor