The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

cut operator problem

kazemi_asgharkazemi_asghar Member Posts: 8 Learner I
hi guys
i have an attribute whit this type of data:
[ { "_id" : "ka5b14ub", "mineralTypeId" : "k5bza8u2", "group" : { "$numberInt" : "3" }, "flloorNo" : { "$numberInt" : "1" }, "wht0003" : { "$numberInt" : "20000000" }, "productionRate" : { "$numberInt" : "2000000" } } ]
i want to cut characters from index 43 to 51.but i face whit this error: string index out of range : -39
can you please help me?
Tagged:

Answers

  • kaymankayman Member Posts: 662 Unicorn
    edited November 2020
    Are you somehow importing this from CSV or xls or so? The comma's used in your string may confuse the workflow. 
    I've mimicked the logic and it should work fine, you should verify what is entering the cut process, to see if it still containing the full string to start with and not cut off somewhat in the middle due to the format of your string...  
  • kazemi_asgharkazemi_asghar Member Posts: 8 Learner I
    edited November 2020
    dear @kayman
    first of all thank you for your attention.
    but i couldn't understand very well what should i do to use cut operator properly.
    i will be thankful if you help me by detaile.

  • kaymankayman Member Posts: 662 Unicorn
    Since your data seems JSON format, why don't you try to use the JSON to Data operator instead? It's part of the text processing extension available on the marketplace in case you don't have it yet, and it nicely converts your string to separate attributes.

    I assume you want to get a certain value out of your string(s) but as they will be different line by line that will never work.
    So you need to use regex or in this case better json path

    Like in attached examples
  • kazemi_asgharkazemi_asghar Member Posts: 8 Learner I
    edited November 2020
    i import excel file and it's(i mean the string) a cell data.
    I've removed all signs such as :']{" and it became like this:
    id k6qk7r1w mineralTypeId k5awyqmg group numberInt 1 flloorNo numberInt 1 productionRate numberInt 120000 wht0003 numberInt 1200000 possibleStorage numberInt 1800000
    then again i've used cut.but in dosen't work at all
  • kaymankayman Member Posts: 662 Unicorn
    Why would you remove all of this? The strength is that these are json strings that make it actually easier to get the content.

    Now, rather than cut you may be better of with the split operator if you want to extract specific data as your cut positions will be different for every row. 

    Would you mind sharing your process and a sample excel file? 
Sign In or Register to comment.