Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 filing in Python 3.7
I have an eternal file in this format: "4b32j","aq8","71yt346" only much longer. I want to load each item one at a time for processing. I can't find how to do this, so I tried to load the whole file and split it up. But it loads as a complete string anyway. I used the code below:

path = '/Users/davidellis/Documents/Python 3 Files/docCodes_File.txt'
test = open(path, 'r')
play = []
print (play)
This just gives me [' "4b32j","aq8","71yt346" ']. If I load it as a string, it still comes in as strings within a string.
Can you suggest how I could open the file and load just one item at a time sequentially, please? I've searched Python help, but could only find material on loading specific lengths or lines, not items.
is the whole file one line (it looks like)? can you post part of the file content in output tags
For simplicity and to keep the file size down, I just created this text file and saved it as Test_File:

"This", "file", "was", "created", "to", "practice", "file", "operations", "in", "Python"

Here's the result of running the code as already posted:

>>> ===== RESTART: /Users/davidellis/Documents/Python 3 Files/ ===== ['"This", "file", "was", "created", "to", "practice", "file", "operations", "in", "Python"'] >>>

Top Page

Forum Jump:

Users browsing this thread: 1 Guest(s)