Goto main content

savecsv

Stores array to a file.

SAVECSV

NAME

savecsv - Stores arrays to a comma-separated file.

SYNOPSIS

savecsv(input,file,delimiter,enclosure,escape,error)

PARAMETERS

input
Array to be stored.
file
File name.
delimiter
Sets the field delimiter. By default, it is set to a backslash (,).
enclosure
Sets the field enclosure character. By default, it is set to a backslash (").
escape
Sets the escape character. By default, it is set to a backslash (").
error
Context to store error messages. Contains errmsg and errcode.

RETURN

Returns true if the operation has succeeded.

EXAMPLES

 if savecsv(
                [
                        ['title1','title2',1.5],
                        ['aaa',123,2.6],
                        [124,'dfg']
                ]
                ,'/test.csv',v) == true
         then
                "true"; else "Can't save CSV"; v; endif;
        if savecsv(
                [
                        ['title1','title2',1.5],
                        ['aaa',123,2.6],
                        [124,'dfg']
                ]
                ,'/test.csv',v) == true
         then
                v.errcode; else "Can't save CSV"; v; endif;
        if savecsv(
                [
                        ['title1','title2',1.5],
                        ['aaa',123,2.6],
                        [124,'dfg']
                ]
                ,'/test.csv') == true
         then
                v; else "Can't save CSV"; v; endif;

        if savecsv(
                input:[
                        ['title1','title2',1.5],
                        ['aaa',123,2.6],
                        [124,'dfg']
                ]
                ,file:'../../../../test.csv',error:v) == true
         then
                "true"; else v; endif

SEE ALSO

{{ include("includes/strings.sn") }}

AUTHOR

Written by Pusnei Sergey and Caroline Laplante, <sergey@sednove.com>

MODIFICATIONS

1.0 2014-09-09 21:24:14 laplante@sednove.com

Edit

© 2024 extenso Inc. All rights reserved.