1. Home
    1. Dashboard
    2. Search
  2. Forum
    1. Unresolved Threads
    2. Members
      1. Recent Activities
      2. Users Online
      3. Team Members
      4. Search Members
      5. Trophys
  3. Articles
  4. Blog
  5. Videos
  6. Jobs
  7. Shop
    1. Orders
  • Login or register
  • Search
This Thread
  • Everywhere
  • This Thread
  • This Forum
  • Articles
  • Pages
  • Forum
  • Blog Articles
  • Products
  • More Options
  1. Robotforum - Support and discussion community for industrial robots and cobots
  2. Forum
  3. Industrial Robot Support and Discussion Center
  4. Fanuc Robot Forum
Your browser does not support videos RoboDK Software for simulation and programming
Visit our Mainsponsor
IRBCAM
Robotics Channel
Robotics Training
Advertise in robotics
Sponsored Ads

read string data from csv- karel

  • vipinpunneri
  • February 19, 2018 at 4:59 AM
  • Thread is Resolved
  • vipinpunneri
    Reactions Received
    6
    Trophies
    3
    Posts
    137
    • February 19, 2018 at 4:59 AM
    • #1

    hello friends

    i was trying to make a program for reading data from csv..
    my data will be like LWP15452,145 i need to read LWP15452 and 145 seperate.. in present i can able to read the entire line ..
    pls help


    thanks
    vipin

    Thanks regards<br />Vipin..

  • inusO
    Trophies
    3
    Posts
    33
    • February 19, 2018 at 9:21 AM
    • #2

    Hello,

    is the number of characters always the same? If so, you can just use the built-in function SUB_STR(source_string , start, len) that return a substring of source_string starting from start character and takes up to len characters

    An example would be:

    Code
    first_part : STRING[8]
    second_part : STRING[3]
    
    
    first_part = SUB_STR(full_line, 1, 8)
    second_part = SUB_STR(full_line, 10, 3)
  • vipinpunneri
    Reactions Received
    6
    Trophies
    3
    Posts
    137
    • February 19, 2018 at 10:09 AM
    • #3
    Quote from inusO


    Hello,

    is the number of characters always the same? If so, you can just use the built-in function SUB_STR(source_string , start, len) that return a substring of source_string starting from start character and takes up to len characters

    An example would be:

    Code
    first_part : STRING[8]
    second_part : STRING[3]
    
    
    first_part = SUB_STR(full_line, 1, 8)
    second_part = SUB_STR(full_line, 10, 3)

    hi...
    thanks for that, but number of characters is not same in my case...

    Thanks regards<br />Vipin..

  • inusO
    Trophies
    3
    Posts
    33
    • February 19, 2018 at 10:30 AM
    • #4

    The standard way would be to use regular expression, but as far as I know there isn't support in Karel.
    A workaround here would be to use some IF clauses and the built-in function STR_LEN to identify how your string is structured or maybe check where the ',' is, that depends on the format of your string.
    Once you have to correct lengths you can use SUB_STR as I shown

  • skalactik
    Reactions Received
    12
    Trophies
    3
    Posts
    111
    • February 19, 2018 at 11:05 AM
    • #5

    Maybe use loops to read each character of the string until any ",' shows up then split the string.

  • vipinpunneri
    Reactions Received
    6
    Trophies
    3
    Posts
    137
    • February 19, 2018 at 11:25 AM
    • #6
    Quote from skalactik


    Maybe use loops to read each character of the string until any ",' shows up then split the string.

    How?? i have checked formatting string data, ::0::2 by using this i can able to separate string with quotes not with comma..........

    Thanks regards<br />Vipin..

  • inusO
    Trophies
    3
    Posts
    33
    • February 19, 2018 at 11:54 AM
    • #7

    This will probably do

    Code
    first_part = ""
    second_part = ""
    change_part = FALSE
    FOR i=1 TO STR_LEN(full_line) DO
      current_character = SUB_STR(full_line, i, 1)
      IF current_character <> ',' THEN
        IF NOT change_part THEN
          first_part = first_part + current_character
        ELSE
          second_part = second_part + current_character
        ENDIF
      ELSE
        change_part = TRUE
      ENDIF
    ENDFOR
    Display More
  • vipinpunneri
    Reactions Received
    6
    Trophies
    3
    Posts
    137
    • February 19, 2018 at 12:49 PM
    • #8
    Quote from inusO


    This will probably do

    Code
    first_part = ""
    second_part = ""
    change_part = FALSE
    FOR i=1 TO STR_LEN(full_line) DO
      current_character = SUB_STR(full_line, i, 1)
      IF current_character <> ',' THEN
        IF NOT change_part THEN
          first_part = first_part + current_character
        ELSE
          second_part = second_part + current_character
        ENDIF
      ELSE
        change_part = TRUE
      ENDIF
    ENDFOR
    Display More

    Hi..

    great this is working.... thanks

    Thanks regards<br />Vipin..

Advertising from our partners

IRBCAM
Robotics Channel
Robotics Training
Advertise in robotics
Advertise in Robotics
Advertise in Robotics

Job Postings

  • Anyware Robotics is hiring!

    yzhou377 February 23, 2025 at 4:54 AM
  • How to see your Job Posting (search or recruit) here in Robot-Forum.com

    Werner Hampel November 18, 2021 at 3:44 PM
Your browser does not support videos RoboDK Software for simulation and programming

Tag Cloud

  • abb
  • Backup
  • calibration
  • Communication
  • CRX
  • DCS
  • dx100
  • dx200
  • error
  • Ethernet
  • Ethernet IP
  • external axis
  • Fanuc
  • help
  • hmi
  • I/O
  • irc5
  • IRVIsion
  • karel
  • kawasaki
  • KRC2
  • KRC4
  • KRC 4
  • KRL
  • KUKA
  • motoman
  • Offset
  • PLC
  • PROFINET
  • Program
  • Programming
  • RAPID
  • robodk
  • roboguide
  • robot
  • robotstudio
  • RSI
  • safety
  • Siemens
  • simulation
  • SPEED
  • staubli
  • tcp
  • TCP/IP
  • teach pendant
  • vision
  • Welding
  • workvisual
  • yaskawa
  • YRC1000

Thread Tag Cloud

  • abb
  • Backup
  • calibration
  • Communication
  • CRX
  • DCS
  • dx100
  • dx200
  • error
  • Ethernet
  • Ethernet IP
  • external axis
  • Fanuc
  • help
  • hmi
  • I/O
  • irc5
  • IRVIsion
  • karel
  • kawasaki
  • KRC2
  • KRC4
  • KRC 4
  • KRL
  • KUKA
  • motoman
  • Offset
  • PLC
  • PROFINET
  • Program
  • Programming
  • RAPID
  • robodk
  • roboguide
  • robot
  • robotstudio
  • RSI
  • safety
  • Siemens
  • simulation
  • SPEED
  • staubli
  • tcp
  • TCP/IP
  • teach pendant
  • vision
  • Welding
  • workvisual
  • yaskawa
  • YRC1000
  1. Privacy Policy
  2. Legal Notice
Powered by WoltLab Suite™
As a registered Member:
* You will see no Google advertising
* You can translate posts into your local language
* You can ask questions or help the community with your knowledge
* You can thank the authors for their help
* You can receive notifications of replies or new topics on request
* We do not sell your data - we promise

JOIN OUR GREAT ROBOTICS COMMUNITY.
Don’t have an account yet? Register yourself now and be a part of our community!
Register Yourself Lost Password
Robotforum - Support and discussion community for industrial robots and cobots in the WSC-Connect App on Google Play
Robotforum - Support and discussion community for industrial robots and cobots in the WSC-Connect App on the App Store
Download