Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 103701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:09:55+00:00 2026-05-11T01:09:55+00:00

I have my CSV file imported as such: records = FasterCSV.read(path, :headers => true,

  • 0

I have my CSV file imported as such:

records = FasterCSV.read(path, :headers => true, :header_converters => :symbol) 

How can I get the unique occurrences of my data? For instance, here some sample data:

ID,Timestamp test,2008.12.03.20.26.32 test,2008.12.03.20.26.38 test,2008.12.03.20.26.41 test,2008.12.03.20.26.42 test,2008.12.03.20.26.43 test,2008.12.03.20.26.44 cnn,2008.12.03.20.30.37 cnn,2008.12.03.20.30.49 

If I simply call records[:id], I just get:

testtesttesttesttesttestcnncnn 

I would like to get this:

testcnn 

How can I do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T01:09:56+00:00Added an answer on May 11, 2026 at 1:09 am

    If your data is not masive you can use the Set class.

    Here’s an example:

    p ['cnn','test','test','test','test','cnn','cnn'].to_set.to_a => ['cnn', 'test'] 

    Here’s a simple benchmark:

    require 'set' require 'benchmark'  Benchmark.bm(5) do |x|   x.report('Set')   do     a = []     20_000.times do |i|       a << 'cnn'<< 'test'     end     a.to_set.to_a   end end  =>            user     system      total        real  Set    0.110000   0.000000   0.110000 (  0.109000) 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a CSV file that holds about 200,000 - 300,000 records. Most of
I have a csv file of the format: 270291014011 ED HARDY - TRUE TO
I have a CSV of file of data that I can load in R
I have a .csv file that is frequently updated (about 20 to 30 times
I have a large CSV file and I want to execute a stored procedure
I have a CSV data file with rows that may have lots of columns
I have an application that reads a CSV file with piles of data rows.
I have a big string (let's call it a CSV file, though it isn't
I have a Ruby script that generates a UTF8 CSV file remotely in a
I have a csv file that has a date field in a format like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.