civis.io.file_to_civis

civis.io.file_to_civis(buf, name, api_key=None, **kwargs)

Upload a file to Civis.

Parameters:

buf : file-like object

The file or other buffer that you wish to upload.

name : str

The name you wish to give the file.

api_key : str, optional

Your Civis API key. If not given, the CIVIS_API_KEY environment variable will be used.

**kwargs : kwargs

Extra keyword arguments will be passed to the file creation endpoint. See post().

Returns:

file_id : int

The new Civis file ID.

Notes

If you are opening a binary file (e.g., a compressed archive) to pass to this function, do so using the 'rb' (read binary) mode (e.g., open('myfile.zip', 'rb')).