DB_Table.write
writepathformaton_existing_filematch_columnson_problems
Group: Output
Documentation
This function writes the table into a file. The specific behavior of the various File_Format
s is specified below.
Arguments
path
: The path to the output file.format
: The format of the file. IfAuto_Detect
is specified; the provided file determines the specific type and configures it appropriately. Details of this type are below.on_existing_file
: Specified how to handle if the file already exists.match_columns
: Specifies how to match columns against an existing file. IfMatch_Columns.By_Name
- the columns are mapped by name against an existing file. If there is a mismatch, then aColumn_Name_Mismatch
error is raised. IfMatch_Columns.By_Position
- the columns are mapped by position against an existing file. If there is a mismatch, then aColumn_Count_Mismatch
error is raised.on_problems
: Specifies how to handle if a problem occurs, raising as a warning by default. The specific issues depend on theFile_Format
argument.
Returns
- If an unsupported
File_Format
is specified, anIllegal_Argument
is raised. - If the path to the parent location cannot be found or the filename is invalid, aFile_Error.Not_Found
is raised. - If another IO error occurs, such as access denied, anFile_Error.IO_Error
is raised. - If appending and the columns do not match, aColumn_Count_Mismatch
is raised. - Other specific errors or warnings that can be raised depend on the format argument. - Otherwise, the file is loaded following the rules of the format parameter.
Examples
Write a database table to a CSV file.
import Standard.Examples
from Standard.Database import all
example_to_csv =
connection = Database.connect (SQLite.From_File (File.new "db.sqlite"))
table = connection.query (SQL_Query.Table_Name "Table")
table.write (enso_project.data / "example_csv_output.csv")
Remarks
File_Format
write behaviors
Auto_Detect
: The file format is determined by the provided file.Bytes
andPlain_Text
: The Table does not support these types in thewrite
function. If passed as format, anIllegal_Argument
is raised. To write out the table as plain text, the user needs to call theText.from Table
method and then use theText.write
function.