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 8377255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:37:24+00:00 2026-06-09T15:37:24+00:00

So far I’ve loaded an entire file into an array (1 line per array

  • 0

So far I’ve loaded an entire file into an array (1 line per array element). Then I’ve learned how to search for the correct lines needed. Now I need to split those lines so I can use the data.

1 array element (1 line from file):
data,data,data,data,data

The first data column is text, the others are numbers.
How do I from here split this data into something so I can do math on just one of these columns or plus 2 together, ect ?

As just a secondary note. I have a file with thousands of lines. But I’m picking 20 elements at a time. So I need to do this for 20 elements that are next to each other. So array[56],57,58, ect.

So I can then do math on row 1 column2 – row 3 column 4. Ect. (if this were set up in excel it would be like this – but you get the point – but it can be set up in any way as long as I can know how to get to individual data)

Thanks in advance.

  • 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. Editorial Team
    Editorial Team
    2026-06-09T15:37:26+00:00Added an answer on June 9, 2026 at 3:37 pm

    You can just use String::split.

    "1,2,3,4,a,b,c,d".split(',')         #=> ["1", "2", "3", "4", "a", "b", "c", "d"]
    

    You can then convert the array elements to integers or floats as needed, as in

    str = "1,2,3,4,a,b,c,d"
    arr = str.split(",")
    
    i = arr[0].to_i
    f = arr[1].to_f
    

    Additionally, if you are working with CSV files, you might consider using Ruby’s CSV library.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So far i wrote a code to download a file from ftp server then
So far, I have been storing the array in a vector and then looping
So far I know that FileSystemWatcher can look into a folder and if any
As far as I know, C2DM is per app per device thing..but my question
so far, I have this: class Foo{ private $plugin_methods = array(); public function registerPlugin($caller,
As far as I can tell this is perfectly valid batch-file code, just a
As far as I know, Google Closure Template doesn't allow passing Java object into
As far as I know, in C programming language, an array is stored on
So far, whenever I set a script tag into a view, that is being
So far I used git update-index --assume-unchanged on the database configuration file after I

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.