Ask Your Question
0

Split Function in LIbreaOffice

asked 2017-06-28 07:24:37 +0200

Sandeep gravatar image

Hi All,

Is there any split function in LibreOffice something similar to SPLIT in google spreadsheets?

I really need to split a large text based on few delimiters.

Please help me.

edit retag flag offensive close merge delete

Comments

Presumably you are getting this from an external file? Can you not set the import filter to split as required?

robleyd gravatar imagerobleyd ( 2017-06-28 09:06:08 +0200 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2017-06-28 15:20:16 +0200

Lupp gravatar image

updated 2017-06-28 19:52:23 +0200

Neither Excel nor Calc offer a Spli function. LibreOffice BASIC does- Even using BASIC it is simple therefore to code a usable SPLIT() function for Calc. There are a lot of possible enhancements.

Example code:

REM  *****  BASIC  *****
Function textSplit(pDelim As String, pSkip As Long, pText As String, Optional pMinCount As Long)
' pSkip is inserted to allow for enhancemnts without a need to rearrange old calls.
' A "0" (zero) passed as a string via pText is supposed to be produced by silly automatims.
' pText is set to "" then.
If pText = 0 Then
    pText=""
End If
REM ** theArray = Split(pText, pDelim)** **USELESS LINE** ** See comment!**
If IsMissing(pMinCount) Then 
    pMinCount=1
End If
theArray = Split(pText, pDelim)
If Ubound(theArray)<(pMinCount - 1) Then
    Redim Preserve theArray(0 To pMinCount-1)
End If
textSplit = theArray
End Function

How to use it is demontraded in this attached spreadsheet document.

(Editing with respect to the comment by @JohnSUN. Thanks!)
The code above was rectified. The attachment-link above now points to a file containing rectified code.

edit flag offensive delete link more

Comments

IMHO the first line theArray = Split(pText, pDelim) is not needed

JohnSUN gravatar imageJohnSUN ( 2017-06-28 18:16:00 +0200 )edit

@JohnSUN is right, of course. (I wrote the code from scratch under bad -bed- circumstances. Finally I missed the silly dub.)

Lupp gravatar imageLupp ( 2017-06-28 19:44:46 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-06-28 07:24:37 +0200

Seen: 804 times

Last updated: Jun 28 '17