summaryrefslogtreecommitdiff
path: root/modules/spreadsheet/help/en_US/csvTextscan.xml
blob: 7030d3aa37a664e523ff98009e1a7b48f1124e79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?xml version="1.0" encoding="UTF-8"?>
<!--
* Copyright (C) 2010-2011 - INRIA - Allan CORNET
* Copyright (C) 2011 - INRIA - Michael Baudin
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-->
<refentry version="5.0-subset Scilab" xml:id="csvTextScan" xml:lang="en"
          xmlns="http://docbook.org/ns/docbook"
          xmlns:xlink="http://www.w3.org/1999/xlink"
          xmlns:svg="http://www.w3.org/2000/svg"
          xmlns:ns3="http://www.w3.org/1999/xhtml"
          xmlns:mml="http://www.w3.org/1998/Math/MathML"
          xmlns:db="http://docbook.org/ns/docbook">
    <refnamediv>
        <refname>csvTextScan</refname>
        
        <refpurpose>Convert a comma-separated value to a matrix</refpurpose>
    </refnamediv>
    
    <refsynopsisdiv>
        <title>Calling Sequence</title>
        
        <synopsis>
            A = csvTextScan(M)
            A = csvTextScan(M, separator)
            A = csvTextScan(M, separator, decimal)
            A = csvTextScan(M, separator, decimal, conversion)
            A = csvTextScan(M, separator, decimal, conversion, range)
        </synopsis>
    </refsynopsisdiv>
    
    <refsection>
        <title>Parameters</title>
        
        <variablelist>
            <varlistentry>
                <term>M</term>
                
                <listitem>
                    <para>a m-by-1 or 1-by-m matrix of strings.</para>
                </listitem>
            </varlistentry>
            
            <varlistentry>
                <term>separator</term>
                
                <listitem>
                    <para>a 1-by-1 matrix of strings, the column separator mark.</para>
                </listitem>
            </varlistentry>
            
            <varlistentry>
                <term>decimal</term>
                
                <listitem>
                    <para>a 1-by-1 matrix of strings, the decimal mark. The available
                        values are "." or ",".
                    </para>
                    <para>
                        If <literal>decimal</literal> is different of <literal>[]</literal> and <literal>conversion</literal> is set to <literal>string</literal>, the decimal conversion will be done.
                    </para>
                </listitem>
            </varlistentry>
            
            <varlistentry>
                <term>conversion</term>
                
                <listitem>
                    <para>a 1-by-1 matrix of strings, the type of the output
                        <literal>A</literal>. Available values are "string" or
                        "double".
                    </para>
                </listitem>
            </varlistentry>
            
            <varlistentry>
                <term>range</term>
                
                <listitem>
                    <para>a 1-by-4 or 4-by-1 matrix of floating point integers, the
                        range of rows and columns which must be read (default range=[],
                        meaning that all the rows and columns). Specify range using the
                        format <literal>[R1 C1 R2 C2]</literal> where (R1,C1) is the upper
                        left corner of the data to be read and (R2,C2) is the lower right
                        corner.
                    </para>
                </listitem>
            </varlistentry>
            
            <varlistentry>
                <term>A</term>
                
                <listitem>
                    <para>a m-by-n matrix of strings or double.</para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    
    <refsection>
        <title>Description</title>
        
        <para>Given an ascii file with delimited fields, this function returns the
            corresponding Scilab matrix of strings or doubles.
        </para>
        
        <para>
            The <literal>csvTextScan</literal> function has the same purpose as
            <literal>csvRead</literal>, except that <literal>csvTextScan</literal>
            reads in a string, while <literal>csvRead</literal> reads in a
            file.
        </para>
        
        <para>The default value of the optional input arguments are defined by the
            <literal>csvDefault</literal> function.
        </para>
        
        <para>Any optional input argument equal to the empty matrix
            <literal>[]</literal> is set to its default value.
        </para>
        
        <para>When input argument "conversion" is equal to "double", strings are
            converted as NaN.
        </para>
    </refsection>
    
    <refsection>
        <title>Examples</title> 
        
        <programlisting role="example"><![CDATA[
// convert a csv string matrix to splitted string or double matrix
A = ["1;3 + i"; "Nan;-Inf"]
B = csvTextScan(A,';')
C = csvTextScan(A,';',[],'double')
//
// Configure the decimal mark.
Atext = [
" 1,000000000D+00; 0,000000000D+00; 2,000000000D+02; Inf; 0,000000000D+00";
" 1,000000000D+00; 1,00000000D-300; 2,000000000D+02; Inf; 0,000000000D+00";
" 1,000000000D+00; 1,00000000D-200; 2,000000000D+02; 3,15000000D+300; 1,020000000D+02";
" 9,999999999D-01; 1,00000000D-100; 2,000000000D+02; 2,960000000D+02; 1,170000000D+02";
" 1,000000000D+00; Inf;-Inf; Nan; 0,000000000D+00"
];
csvTextScan( Atext , ";" , "," )
    ]]>
        </programlisting>
    </refsection>
    
    <refsection>
        <title>See Also</title>
        
        <simplelist type="inline">
            <member>
                <link linkend="csvRead">csvRead</link>
            </member>
        </simplelist>
    </refsection>
    <refsection>
        <title>History</title>
        <revhistory>
            <revision>
                <revnumber>5.4.0</revnumber>
                <revremark>Function introduced. Based on the 'csv_readwrite' module.</revremark>
            </revision>
            <revision>
                <revnumber>5.4.1</revnumber>
                <revremark>
                    If <literal>decimal</literal> is different of <literal>[]</literal> and <literal>conversion</literal> is set to <literal>string</literal>, the decimal conversion will be done.
                </revremark>
            </revision>
        </revhistory>
    </refsection>
</refentry>