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

  • Home
  • SEARCH
  • 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 5953221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:47:37+00:00 2026-05-22T17:47:37+00:00

I have a csv file with traceroutes, the last entry in every row is

  • 0

I have a csv file with traceroutes,
the last entry in every row is the target IP,
but as there are variable no of records in every row …so I am having difficulty
I want to collect the last entry from every row into a column

how do I do that?

  • 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-05-22T17:47:38+00:00Added an answer on May 22, 2026 at 5:47 pm

    PHP has a nice function fgetcsv().

    Example:

    if (($handle = fopen("x.csv", "r")) !== FALSE)//your file
    {
        echo "<table><tr><th>Row</th><th>ID</th><th>Name</th></tr>";
        $num_rows = 7440; //number of rows in your CSV file.
        for($w=0; $w<$num_rows; $w++)
        {
            $data = fgetcsv($handle, 1000, ",");
            echo "<tr>
            <td>{$w}</td>
            <td>{$data[0]}</td>
            <td>{$data[1]}</td>
            </tr>";
        }
        echo "</table>";
        fclose($handle);
    }
    else
    {
        die('fopen failed');
    }
    

    To collect the value from the last cell in each row, do the following inside the for loop:

    echo $data[(count($data)-1)];
    

    Although, this only needs to be done if the number of cells in each row varies or if you actually don’t know.
    Otherwise do what’s in the example above and just specify it; e.g. if the last cell in each row is always in column C then you collect the value from $data[2] (in the for loop)

    • 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 with the following entries. The last entry is location.
I have a csv file to read, but in one column there are some
I have 2 csv files One has traceroutes to different IP addresses(The last entry
I have a CSV file with several entries, and each entry has 2 unix
I have a csv file where each row is a different type of record.
I have a csv file in a format resembling the following. There are no
I have a CSV file that holds about 200,000 - 300,000 records. Most of
I have my CSV file imported as such: records = FasterCSV.read(path, :headers => true,
I have a csv file with 350,000 rows, each row has about 150 columns.
I have a csv file where each row defines a room in a given

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.