Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Reading a text file

    Scheduled Pinned Locked Moved SiPy
    readline
    4 Posts 2 Posters 1.6k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P Offline
      pmulvey
      last edited by

      My main.py is:

      main.py -- put your code here!

      print ("In main...")
      import setup_wifi
      print ("WiFi setup...")
      import ReadFile

      ReadFile.py is:
      print ("In ReadFile...")
      file = open('02_250.txt', 'r')
      file.close()

      Getting OSError Errno 2 ENOENT on file = open('02_250.txt', 'r')

      I am returning to the SiPy after 6 months and I'm sure this worked back then.

      robert-hhR 1 Reply Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @pmulvey
        last edited by

        @pmulvey The error code just tells that the file does not exist. I made such a file as "/flash/02_250.txt", and successfully tried the three lines:

        file = open('02_250.txt', 'r')
        content=file.readlines()
        file.close()
        
        1 Reply Last reply Reply Quote 0
        • P Offline
          pmulvey
          last edited by

          @pmulvey said in Reading a text file:

          02_250.txt

          Got myself in a muddle having the file in the PC window of WinSCP and not on the device! Thanks for the reply. Oh, what are the special characters that signify a code block (black background) on the forum?

          robert-hhR 1 Reply Last reply Reply Quote 0
          • robert-hhR Offline
            robert-hh @pmulvey
            last edited by

            @pmulvey three backticks start and end a code block,

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • 1 / 1
            • First post
              Last post

            Pycom on Twitter

            Pycom