Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
FSternberg
Contributor III
Contributor III

Cut only last characters from one file name ((String)globalMap.get("tFileList_1_CURRENT_FILE")

Only one doubt, how can I to cut the last characters from one file name using  ((String)globalMap.get("tFileList_1_CURRENT_FILE"))?

 

Example:

 

Actual file name:

 DALUNOS_RH

_20211222

Necessary:

DALUNOS_RH

I tried as below but the job show me DALUNOS_RH_202 ....

((String)globalMap.get("tFileList_1_CURRENT_FILE")).substring(0,((String)globalMap.get("tFileList_1_CURRENT_FILE")).length() - 9)

 

 

Labels (3)
6 Replies
Anonymous
Not applicable

You can try expression:

((String)globalMap.get("tFileList_1_CURRENT_FILE")).substring(0, ((String)globalMap.get("tFileList_1_CURRENT_FILE")).lastIndexOf("_"))

FSternberg
Contributor III
Contributor III
Author

Hello thanks and only one more doubt, if in case I have as the following: DALUNOS_RH_211203

How can I cut _211203?

thanks a lot

VenkyM
Contributor
Contributor

  1. if the length is fixed width, you can use stringhandling function.
  2. if the length is not fixed, you can use delimiter function (delimiter is "_") and take only the first two words.
Anonymous
Not applicable

cut the string from last index of "_",

((String)globalMap.get("tFileList_1_CURRENT_FILE")).substring(((String)globalMap.get("tFileList_1_CURRENT_FILE")).lastIndexOf("_"))

FSternberg1638555481
Contributor
Contributor

Hello,

The lenth is fixed at the end but I need of .CSV for example.

 

DALUNOS_RH_20211228_125745.CSV

To be: : DALUNOS_RH.CSV

 

Could you give me one example of the line commnand to keep the .csv?

thanks

 

FSternberg
Contributor III
Contributor III
Author

I solved it thanks