Skip to main content

Save-CSV-File

Command Description

Save CSV File

Command Prototype

CSV.Save(objData,sPath,optionArgs)

Parameter Description

ParameterRequiredTypeDefaultDescription
objDataTrueexpressionobjDataThe data table object to be saved. Can be the data table object opened with CSV.Open, or the data table object returned by the database (the field name will be written as the first row)
sPathTruepath'''C:\Users'''To save the CSV file to the path: If an empty string is passed, then the file will be saved to the original path, otherwise it will be saved to a new location. If the data table is not opened with CSV.Open and the attribute is filled with an empty string, an error will occur
encodingNoneenum"gbk"File encoding. Use ANSI encoding when "ansi" is passed. Use utf-8 encoding when "utf8" is passed. Use utf-16 encoding when "unicode" is passed and use utf-8-sig encoding when "UTF-8 with BOM" is passed

Demo

/************************************Save CSV file************ ************************ 
Command prototype:
CSV.Save(objData,'''C:\Users''',{"encoding": "gbk"})
Input parameters:
objData--Data table object to be saved
sPath--the path to save the CSV file to
encoding--file character set encoding (optional)
Outgoing parameters:
None
********************************************************************************/
Dim objData= [["name","age"],["Bieber","27"]]
Dim sPath='''C:\Users\Chance\Desktop\testData.csv'''
CSV.Save(objData, sPath,{"encoding": "gbk"})