Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

split cells

by rajkrishna89 (Acolyte)
on Feb 20, 2012 at 10:50 UTC ( #955037=perlquestion: print w/replies, xml ) Need Help??
rajkrishna89 has asked for the wisdom of the Perl Monks concerning the following question:

hi monks im creating an excel sheet and im writing some data in the cells..Example

Cell A1(in excel Sheet) main check check1 main check2 check3 main Perl Monks

I can go to Data->text to columns in the excel sheet and i can split the cells (using spaces) as follows:

A1 B1 C1 main check check1 main check2 check3 main perl monks

Is there any way to split the data in the cells using perl?

Help out Monks

Replies are listed 'Best First'.
Re: split cells
by moritz (Cardinal) on Feb 20, 2012 at 11:06 UTC

    Could it be that this excel file is the result of incorrectly importing a (comma/space/tab) separated file into excel?

    If yes, I'd recommend fixing the import in the first place (you can configure the separator in excel directly) instead of fixing up the resulting file in another step.

Re: split cells
by McDarren (Abbot) on Feb 20, 2012 at 11:00 UTC
    Is there any way to split the data in the cells using perl?

    1. Open the worksheet using your favourite Excel processing module
    2. Read the data from each cell
    3. split on whitespace
    4. Write the data back into the worksheet


      Yes, follow up below:
      * import module to parse xls. (This will help to modify your same cell of same file)
      * Read that cell text.
      * Split that cell text into newline. (@line=split '\n',cellvalue)
      * Split that line into tabspace (@innerline=split '\t',$line(index)
      * Now write each index position value of @innerline into different cells.
      Hope this will help.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://955037]
Approved by marto
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2018-02-26 00:22 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (315 votes). Check out past polls.