Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
extract to dictionaries
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Gary Herron, post: 3870722"] OK. Assuming you are open a file with something like: f = open('data', 'r') Then this will read lines up to the first "parameters" line for line in f: if line.startswith('parameters'): break At this point, line contains 'parameters1\n'. Do with it as you will. Then read and process lines until an end line is reached for line in f: if line.beginswith('end'): break # Here line contains ' key1 value1\n'. # Perhaps use line.strip to remove the white space on each end # and k,v =line.split() to split out the two values on the line. You'll need more: A loop to keep the above two going until the end of file A way to recognize the end of the file. Gary Herron [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
extract to dictionaries
Top