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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:02:48+00:00 2026-06-17T11:02:48+00:00

I have a data file that I need to use an input for a

  • 0

I have a data file that I need to use an input for a program, but I need to tweak the formatting a little. Using this method: Extracting specific data from a file and writing it to another file I generated a file that looks like this:

PITG_00002  2   397
PITG_00004  1   1275
PITG_00004  1397    1969
PITG_00005  200 1111
PITG_00005  1281    1646
PITG_00006  1   816
PITG_00009  2398    3276
PITG_00009  1536    1952
PITG_00010  1   537

I need to distinguish between data that comes from the same sequence (first column) and data that comes from different sequences, by adding a blank line in between sequences that are unique, so that it looks like:

PITG_00002  2   397

PITG_00004  1   1275
PITG_00004  1397    1969

PITG_00005  200 1111
PITG_00005  1281    1646

PITG_00006  1   816

PITG_00009  2398    3276
PITG_00009  1536    1952

PITG_00010  1   537

I tagged this with the program/coding options available to me. Any help you could give is much appreciated, thanks!

  • 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-17T11:02:49+00:00Added an answer on June 17, 2026 at 11:02 am
    perl -pae 'print $/ if (defined $x && $x ne $F[0]); $x = $F[0];' input.txt
    

    This will check the first field $F[0] against the previous field, stored in $x. If they are not the same, a newline is printed.

    Explanations:

    • -p read file and print each line
    • -a autosplit lines on whitespace into @F array
    • $/ is your input record separator, default is newline.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a txt file that contains data which I need to input to
I have a pgp-encrypted file that I need to extract data from at runtime.
I have an Excel file that gets external data from database table. I need
I have a data file that looks like this: xyz123 2.000 -0.3974 0.0 hij123
I have a file that was encrypted using AES. I use the following NSData
I have a data file that looks like the following example. I've added '%'
Say I have a data file that I want to process; I want to
I have a text data file that I likely will read with readLines .
I have an HTML (App) file that reads another HTML (data) file via jQuery.ajax()
I have a number of images and a CSV data file that I want

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.