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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:34:12+00:00 2026-05-31T16:34:12+00:00

How can I trim these 7 columns down to 5 columns, by running some

  • 0

How can I trim these 7 columns down to 5 columns, by running some script of sorts.

I recall you can do this using regex / php but buggered if I can recall how we did it.

Example code ( of a GEO IP db ( 115,000 lines )

"3231296768","3231297023","ripencc","702518400","EU","EU","European Union"
"3231297024","3231297279","ripencc","441763200","EU","EU","European Union"
"3231297280","3231297535","ripencc","702518400","EU","EU","European Union"
"3231297536","3231297791","ripencc","702518400","EU","EU","European Union"
"3231297792","3231298047","ripencc","702518400","EU","EU","European Union"
"3231298048","3231298303","ripencc","702518400","EU","EU","European Union"
"3231298304","3231298559","ripencc","702518400","EU","EU","European Union"

I need to remove columns 3 and 4 from every line.

Any help appreciated.

  • 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-31T16:34:13+00:00Added an answer on May 31, 2026 at 4:34 pm

    While jimw’s answer is the best answer in general, if you want a pure PHP solution I would suggest the following:

    $input = 'input.txt';
    $output = 'output.txt';
    
    if (false !== ($ih = fopen($input, 'r'))) {
        $oh = fopen($output, 'w');
    
        while (false !== ($data = fgetcsv($ih))) {
            // this is where you build your new row
            $outputData = array($data[0], $data[1], $data[4], $data[5], $data[6]);
            fputcsv($oh, $outputData);
        }
    
        fclose($ih);
        fclose($oh);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking to create a PHP function that can trim each line in a
How can I this PHP function include in jquery .html? PHP function: function trim_text($string,
Can I use these PHP functions below: $user = mysql_escape_string($user); $user = filter_var($user, FILTER_SANITIZE_STRING);
I can use the following codes to trim a string: -(void) aMethod { //
When you use the Trim() method on a string object, you can pass an
can you recommend some good ASP.NET tutorials or a good book? Should I jump
I am retrieving value from my notepad(database) like this strLine = br.readLine().trim(); if ((strLine.length()!=0)
Can someone please take a look at these, it just is not happing for
I have a working php guestbook script. It's only 1 file. I tried to
I have done some research and still confused, This is my outcome of that

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.