Read from txt file

Typically: "How do I... ", "How can I... " questions
Post Reply
blackbird
Posts: 6
Joined: 09 Mar 2022, 12:01

Read from txt file

Post by blackbird »

Hi, i want to move robot by reading from txt file with python. How can i do that?

fferri
Posts: 865
Joined: 09 Sep 2013, 19:28

Re: Read from txt file

Post by fferri »

Code: Select all

#python

from zmqRemoteApi import RemoteAPIClient
client = RemoteAPIClient()
sim = client.getObject('sim')

with open('file.txt','rt') as f:
    for line in f:
        # do something with line
        # e.g. parse value then call sim.setJointTargetPosition

coppelia
Site Admin
Posts: 9362
Joined: 14 Dec 2012, 00:25

Re: Read from txt file

Post by coppelia »

Or, from within CoppeliaSim:

Code: Select all

#python

def sysCall_thread():
    with open('file.txt','rt') as f:
        for line in f:
            print(line)
Cheers

blackbird
Posts: 6
Joined: 09 Mar 2022, 12:01

Re: Read from txt file

Post by blackbird »

Thanks...

Post Reply