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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:42:49+00:00 2026-05-23T06:42:49+00:00

I have an Excel/CSV file with relatively simple format. 1|2|3|4|10|20|30 | | | |40|50|60

  • 0

I have an Excel/CSV file with relatively simple format.

1|2|3|4|10|20|30
 | | | |40|50|60
 | | | |70|80|90
9|8|7|6|01|02|03
 | | | |04|05|06
 | | | |07|08|09
 | | | |10|11|12

The complete rows of 7 fields are single items, while the repeating columns of 5, 6 and 7 represent the data I want to serialise. Each main row can have any number of partial rows associated.

So for the above, item 1, the data to serialise is:

 | | | |10|20|30
 | | | |40|50|60
 | | | |70|80|90

Same for item 2, although the cell content is completely arbitrary, except for the number of items.

Output would be below to get the serialised data, except rather than print to page it needs to go back in to the CSV, as column 8, with the additional rows (2-3, 5-6 in this case) deleted.

If I can achieve the below, then it would be great:

<?
$line_1 = array(
    array('1' => '10', '20', '30'), 
    array('1' => '40', '50', '60'), 
    array('1' => '70', '80', '90'), 
);
$line_2 = array(
    array('1' => '01', '02', '03'), 
    array('1' => '04', '05', '06'), 
    array('1' => '07', '08', '09'), 
    array('1' => '10', '11', '12'), 
);
echo serialize($line_1);
echo serialize($line_2);
?>  

So finally:

1|2|3|4|10|20|30|serialize($line_1)
9|8|7|6|01|02|03|serialize($line_2)

Then it would just be a case of getting it written to the parent line.

Output of the first line would be as follows and written to col H:

1|2|3|4|10|20|30|a:3:{i:0;a:3:{i:1;s:2:"10";i:2;s:2:"20";i:3;s:2:"30";}i:1;a:3:{i:1;s:2:"40";i:2;s:2:"50";i:3;s:2:"60";}i:2;a:3:{i:1;s:2:"70";i:2;s:2:"80";i:3;s:2:"90";}}

Is it possible to do that in Excel without PHP intervention, and if not how can it be done in PHP?

  • 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-23T06:42:50+00:00Added an answer on May 23, 2026 at 6:42 am

    Because the question changed a bit, I’m going to give a new answer. Hope this helps.

    <?php
    
      $array_to_serialize = array();
      $output_array = array();
      $in_lines = array();
    
      $in_csv = '1,2,3,4,10,20,30' . "\r\n" .
                ',,,,40,50,60' . "\r\n" .
                ',,,,70,80,90' . "\r\n" .
                '9,8,7,0,01,02,03' . "\r\n" .
                ',,,,40,11,60' . "\r\n" .
                ',,,,70,80,90' . "\r\n" .
                '9,8,7,6,01,02,03' . "\r\n" .
                ',,,,04,05,06' . "\r\n" .
                ',,,,07,08,09';
    
    
      $in_lines = explode("\n", $in_csv);
    
      while (list(, $line) = each($in_lines)) {
    
        $line_parts = explode(",", trim($line));
    
        if ($line_parts[0] != '') {
    
          if (!empty($beginning_numbers)) {
            $output_array[] = implode(',', $beginning_numbers) . ',' . serialize($matrix_part);
          }
    
          $beginning_numbers = array_slice($line_parts, 0, 4);
          $matrix_part = array(array_slice($line_parts, 4));
    
          $output_line = $line_parts;
          $array_to_serialize = array();
        } else {
          $matrix_part[] = array_slice($line_parts, 4);
        }
    
      }
    
      $output_array[] = implode(',', $beginning_numbers) . ',' . serialize($matrix_part);
    
      $out_text = implode("\r\n", $output_array);
    
      echo $out_text;
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several excel files carrying 90 columns and about 500 rows, each file
I have a web page where it will input an excel/CSV file from the
I have a large collection of data in an excel file (and csv files).
I have an excel file which has more than 65536 rows. However, I can
I have a Excel .CSV file I'm attempting to read in with DictReader. All
I have a CSV file that I'm totaling up two ways: one using Excel
Have a program that's dynamically generating an Excel file and a csv. The excel
I have a simple JSP to download a csv file containing Japanese characters. Downloaded
Hi I have a csv file (coming from excel), and I use BULK INSERT
I have been trying to generate data in Excel. I generated .CSV file. So

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.