Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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

Comment on split cells
Select or Download Code
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?
    Yes.

    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

    Cheers,
    Darren

      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.
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://955037]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (10)
As of 2014-07-23 11:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (140 votes), past polls