2

I am trying to create csv file using python and than to upload that file to azure blob storage. I am able to create csv file, that part works fine, but when I try to upload the file to blob:

blob.upload_blob(data=df.to_csv("capacity.csv",index=False))

I get error message:

Traceback (most recent call last):
  File ".\blob.py", line 94, in <module>
    blob.upload_blob(data=df.to_csv("data.csv",index=False))
  File "C:\Python38\lib\site-packages\azure\core\tracing\decorator.py", line 83, in wrapper_use_tracer    return func(*args, **kwargs)
  File "C:\Python38\lib\site-packages\azure\storage\blob\_blob_client.py", line 489, in upload_blob   
    options = self._upload_blob_options(
  File "C:\Python38\lib\site-packages\azure\storage\blob\_blob_client.py", line 332, in _upload_blob_options
    raise TypeError("Unsupported data type: {}".format(type(data)))
TypeError: Unsupported data type: <class 'NoneType'>

After that I tried to upload some local csv file, just to test if it is working:

with open(path_to_file, "rb") as data:
   blob.upload_blob( data=data)

And it worked. I am not sure what is causing this error, I spent some time looking for solution, but nothing is working for me.

1 Answer 1

2

You are converting a .csv-File to csv again:

blob.upload_blob(data=df.to_csv("capacity.csv",index=False))
                                 ^

But you should convert your DataFrame to csv:

blob.upload_blob(data=df.to_csv(index=False))
                                
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you bro, you helped me a lot. Your suggestion did not fixed my problem, but you forced me to look again at documentation and than I figured out. Correct approach is: blob.upload_blob(data=df.to_csv(index=False))
Good to hear! I fixed it in the solution above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.