Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Remove First and Last Character in Loadscript OR Remove Two Characters from Loadscript

Hello!

Here's the problem, my data is coming in wrapped in square brackets, e.g. [www.google.com]

Can I remove the square brackets, either by:

1. Removing the first and last character of a line in the loadscript?

2. Removing all '[' and ']' from my data?

Thanks!

Alex

1 Solution

Accepted Solutions
cesaraccardi
Specialist
Specialist

Hi Alex,

There are multiple ways to achieve that, see examples below.

1. Removing the first and last character of a line in the loadscript?

A. This will ignore the first and last character:

LOAD

     mid(Field,2,len(Field)-1) as Field

(...);

B. This will look for the brackets to get what's in between then:

LOAD

     textbetween(Field,'[',']') as Field

(...);

2. Removing all '[' and ']' from my data?

C. This will remove any occurence of brackets in any position:

LOAD

     PurgeChar(Field,'[]') as Field

(...);

Hope this helps you.

Cesar

View solution in original post

5 Replies
crusader_
Partner - Specialist
Partner - Specialist

Hi,

Use below expression:

LOAD

     PurgeChar(Field,'[]') as New_Field

FROM datasource;

Hope this helps you.

Regards,

Andrei Kaliahin

cesaraccardi
Specialist
Specialist

Hi Alex,

There are multiple ways to achieve that, see examples below.

1. Removing the first and last character of a line in the loadscript?

A. This will ignore the first and last character:

LOAD

     mid(Field,2,len(Field)-1) as Field

(...);

B. This will look for the brackets to get what's in between then:

LOAD

     textbetween(Field,'[',']') as Field

(...);

2. Removing all '[' and ']' from my data?

C. This will remove any occurence of brackets in any position:

LOAD

     PurgeChar(Field,'[]') as Field

(...);

Hope this helps you.

Cesar

Not applicable
Author

Thank you!

Not applicable
Author

Thank you!

maxgro
MVP
MVP

remove first and last from field

load

     field,

     mid(field, 2, len(field)-2)

......