0

I'm developing a Python script to download a .csv file for data from a set of pumps via IP. However, there is an error in the passage >> lines = download.content.split ("\ n") << that I can not understand. In the end, I want to break the list and grab the first 4 rows of data from the first 2 columns (time and pump1).

import requests

url = "http://10.0.4.49/get.cgi?menu=download_logvalues"
local_output_file = "B51.csv"

s = requests.Session()
s.auth = ("admin", "admin")
download = s.get(url)
lines = download.content.split("\n")

time = []  # Initially empty time stamp.
pump1 = [] # Pump 1 data (column B of the .csv file)

i=4 # Reading data only, excluding the header - beginning from the 4th line
while (i<=8):
    time.append(lines[i].split(";")[0])
    pump1.append(lines[i].split(";")[1])
i += 1

print (time)
print(pump1)


>>> 
Traceback (most recent call last):
  File "C:\Python34\teste 0802.py", line 14, in <module>
  lines = download.content.split("\n")
TypeError: 'str' does not support the buffer interface
>>> 

Data B51_csv.jpg

0 Answers0