civis.io.civis_file_to_table¶
-
civis.io.civis_file_to_table(file_id, database, table, client=None, max_errors=None, existing_table_rows='fail', diststyle=None, distkey=None, sortkey1=None, sortkey2=None, delimiter=', ', headers=None, credential_id=None, polling_interval=None, hidden=True)[source]¶ Upload the contents of a Civis file to a Civis table.
Parameters: - file_id : int
Civis file ID.
- database : str or int
Upload data into this database. Can be the database name or ID.
- table : str
The schema and table you want to upload to. E.g.,
'scratch.table'.- client :
civis.APIClient, optional If not provided, an
civis.APIClientobject will be created from theCIVIS_API_KEY.- max_errors : int, optional
The maximum number of rows with errors to remove from the import before failing.
- existing_table_rows : str, optional
The behaviour if a table with the requested name already exists. One of
'fail','truncate','append'or'drop'. Defaults to'fail'.- diststyle : str, optional
The distribution style for the table. One of
'even','all'or'key'.- distkey : str, optional
The column to use as the distkey for the table.
- sortkey1 : str, optional
The column to use as the sortkey for the table.
- sortkey2 : str, optional
The second column in a compound sortkey for the table.
- delimiter : string, optional
The column delimiter. One of
',','\t'or'|'.- headers : bool, optional
Whether or not the first row of the file should be treated as headers. The default,
None, attempts to autodetect whether or not the first row contains headers.- credential_id : str or int, optional
The ID of the database credential. If
None, the default credential will be used.- polling_interval : int or float, optional
Number of seconds to wait between checks for job completion.
- hidden : bool, optional
If
True(the default), this job will not appear in the Civis UI.
Returns: - results :
CivisFuture A CivisFuture object.
Examples
>>> file_id = 100 >>> fut = civis.io.civis_file_to_table(file_id, ... 'my-database', ... 'scratch.my_data') >>> fut.result()