I have two quick python questions. This is my first experience with python; I have almost no programming experience whatsoever so I apologize - this is a very basic question and I know it should be easy. I did search for existing answers but could not find anything that helped.
Basically, I have a .txt file that keeps up with 31 variables. There is a header at the top with category names, and then the following lines are just the entries. It looks like this:
date time parameter3 ... parameter31
d1 t1 p3_1 ... p31_1
d2 t2 p3_2 ... p31_2
etc.
All of the parameters are numerical, except for parameter6, which will be either a string of three letters or if it is empty will be "..."
The .txt file is not comma-separated; only one to three whitespaces separate each value.
I am trying to import this text file into Python, create a list out of each line, and then have Python check parameter7 and parameter9. If parameters 7 is <30 and parameter 9 is <35, I want Python to take that entry and output it to a new .txt file. If either of these conditions does not hold, I want it to ignore that particular line and move on. How should I go about writing such a program?
This is the only thing I found that was similar to my problem: How to Convert a Text File into a List in Python
However, the above assumes the .txt file is already comma-separated.
Thank you for your help!
Using line.split() in order to get the fields should work for you.
for example: