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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:34:35+00:00 2026-05-23T15:34:35+00:00

I have a .dat file that is essentially ; delimited file and I’m trying

  • 0

I have a .dat file that is essentially ; delimited file and I’m trying to convert it to a tab delimited .txt. The problem that I am not sure about is that each row of the new file will be a combination of 3 of the original file’s rows, each original row has a different quantity of data. The first column just identifies each row in a grouping. What would be the best way to do this?

Sample original data:

01;zxc;asd;qwe;uio;jkl;asd;123;456
02;lkj;oiu;oji
03;fjifao;vbofekjf;fjieofk;aoijf;voien3984
01;lkj;oiu;fji;eoj;vnk;fji;098;321
02;fji;oje;jvi
03;jie;voi;djv;eojf;38723

End output:

zxc   asd   qwe   uio   jkl   asd   123   456   lkj   oiu   oji   fjifao   vbofekjf   fjieofk   aoijf   voien3984
lkj   oiu   fji   eoj   vnk   fji   098   321   fji   oje   jvi   jie   voi   djv   eojf   38723

Any ideas?

  • 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-23T15:34:35+00:00Added an answer on May 23, 2026 at 3:34 pm

    Here’s how I’d do it:

    $lines = file($data);
    $rows = array();
    $row_pivot = -1;
    foreach ($lines as $line) {
    
        // Split line by ;
        $data = explode(';', trim($line));
    
        // Get the first element
        $r_id = array_shift($data);
        if ($r_id == '01') {
            // When 01 is the first element, start a new row
            // You can dump the previous row here as well if you aim for speed
            $row_pivot++;
            $rows[$row_pivot] = array();
        }
    
        // Add data to row
        $rows[$row_pivot] = array_merge($rows[$row_pivot], $data);
    }
    
    // Print rows
    foreach ($rows as $r) {
        echo implode("\t", $r)."\n";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to open a .dat file in Excel, which is tab delimited,
I have semicolon-separated .dat file and I want to read that file and store
I have a matlab GUI....I'd like to load ANY file type(doc,txt,dat,xls) into matlab as
So I have a python program that ends up leaving a .dat file from
I have a program that searches a file (numbers.dat) using a binary search and
I have a jar file that contains two files in the root tbs.jar -parser.dat
I have a file numbers.dat containing about 300 numbers(floating point,negative positive)in column format. The
I have a txt(ascii) file but i wish to convert this file into binary
I am trying to read in a file that only have one column, and
I have a vector in R that looks like this: dat <- c(TRUE, TRUE,

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.