如何解决错误=' str'不支持缓冲区接口

时间:2017-03-03 18:25:37

标签: python csv

我正在开发一个Python脚本,通过IP从一组泵下载数据的.csv文件。但是,通道中存在错误>> lines = download.content.split(" \ n")<<我无法理解。最后,我想打破列表并从前2列(时间和pump1)中获取前4行数据。

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 个答案:

没有答案