Reputation: 109
I need to read a particular value from a csv file. The sample below is the first three line of my input csv file. I need to read the value 60 and save it in a variable.This value can change with every other input csv file.
Start Time: 2/21/19 3:50 PM
RDT Sample Rate: 60
"PLEASE NOTE: The sample rate is read...
Upvotes: 1
Views: 77
Reputation: 36
You don't need pandas for that, a simple function will do the trick :
def find_num(path):
f = open(path)
f.readline()
return int(f.readline()[:-1].replace('RDT Sample Rate: ', ''))
Upvotes: 2
Reputation: 106
Is this the csv file itself? If so it looks like bad format. I would try
Start Time, RDT Sample Rate,
"2/21/19 3:50 PM", "60",
and then you should be able to reference what you need to.
Upvotes: 1