Office365-REST-Python-Client
Office365-REST-Python-Client copied to clipboard
Reading file connection breaking, concurrent issue?
Hey I have begun to notice that when reading a csv file with the following function, I'm getting a connection break error. My first thought is that I'm reading a file that gets overwritten often, so I'm wondering if I'm experiencing a concurrent issue, where one program is reading a file that is in process of being written to by another program?
error: <class 'requests.exceptions.ChunkedEncodingError'> 214 ("Connection broken: ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)", ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)) None <class '
func that reads file
def read_csv(ctx, relative_url, pandas=False): ##### read csv bytesstring decoded data ####
# relative_url = "/sites/mysite/folder/file.csv"
# ctx = auth()
response = File.open_binary(ctx, relative_url)
bytes_data = response.content
try:
s = str(bytes_data, 'utf8')
except Exception as e:
print('utf8 encoding error')
print(relative_url, e)
try:
s = str(bytes_data, 'cp1252')
except Exception as e:
print('CRITIAL ERROR cp1252 encoding error')
print(relative_url, e)
if pandas == False:
return s
else:
data = StringIO(s)
return data
did you fix it?