22.11.6.4 Read CSV File
Reads data in cell units from a CSV file
(constructed from a cell image delimited with ","), and writes it
to a word address.
_CF_read_csv/_USB_read_csv (folder names,
file names, save in addresses, start line, the number of lines
read)

-
Parameter 1: Text (Up to 32 single-byte
characters)
-
Parameter 2: Fixed string (Maximum length is 32
single-byte characters), Internal Device (Maximum length is 14
single-byte characters), Internal Device designated with offset
(Internal Device + Temporary address, Maximum length is 14
single-byte characters)
-
Parameter 3: Internal Device, Internal Device
designated with offset
-
Parameter 4: Numeric Value (1 to 65535), Internal
Device, Temporary variable
-
Parameter 5: Numeric Value (1 to 65535), Internal
Device, Temporary variable
Example expression:
_CF_read_csv ("\CSV", "SAMPLE.CSV",
[w:[#INTERNAL]LS1000], 1, 2)
(When reading two lines of data, starting from the first line of
the [\CSV\SAMPLE.CSV] file in the CF memory card using the
"_CF_read_csv ( )" function)
SAMPLE.CSV
Reads two lines of data, starting from the first line of the CSV
file. When the first character is a numerical value ("0" to "9" or
"-"), the data is stored as a numerical value. When the first
character is ["], the data is treated as a character and "00h" is
stored at the end of the text string. For example, when storing
"DAT01-01" the data size is 8 characters, which is an even number,
and a total of five words are used: Four words are used for storing
the text string, and one word is used for storing "00h" at the
end.
For example, when storing "DAT01-2" the data size is 7
characters, which is an odd number, and a total of 4 words are used
to store the text, with "00h" stored at the end.
-
When the first character in the cell is a
numerical value ("0" to "9", "-"), it converts the value to
numerical data and then writes the data to the LS device. The
allowed range is from -32768 to 32767.
-
When the first character in the cell is ["], it
writes the range with ["] to the LS device as text string data.
When the size of the text string data is an odd number of bytes,
"0x00" is appended to the end. When the size of the text data is an
even number of bytes, "0x0000" is written to the address following
the last address.
-
When a CSV file has two or more lines of data,
the desired number of lines can be read out starting from the
specified line. Up to 200 single-byte characters can be entered in
a line, and up to 65,535 lines can be entered in a CSV file.
-
When an error occurs, the error status is
written in LS9137 (LS9143 for USB storage).
-
When writing CSV file text data to the LS
device, the data storage order depends on the data storage
mode.
Error Status
Editor Function Name
|
LS Area
|
Error Status
|
Cause
|
_CF_read_csv( )/ _USB_read_csv( )
|
LS9137/
LS9143
|
0000h
|
Completed Successfully
|
0001h
|
Parameter error
|
0002h
|
CF Card/USB storage error
No CF Card or USB Storage/File open error/File
read error
|
0003h
|
Write/Read error
|
-
When "*" is specified for the folder name,
the full path can be designated for the file name.
-
Only the 8.3 format (a maximum of 12
characters, with 8 characters for the file name, the period, and 3
characters for the extension) can be used for the file name. You
cannot use file names longer than 12 characters.
-
Maximum length of parameter 1 folder name is
32 single-byte characters.
-
The folder name can be appended to the
parameter 2 file name. Maximum length of parameter 2 folder name +
file name is 32 single-byte characters.
For example, \DATA\01\DATA.bin
-
An Internal Device can be specified for the
second parameter (File name). Specifying Internal Device allows
indirect addressing of a file name. Also, when using internal
devices the maximum folder name + file name length is 14
single-byte characters.
-
The effective LS device area for storing
data imported from a CSV file is limited to the designated user
area (LS20 to LS2031 and LS2096 to LS8191).
-
The processing time required for importing
data is proportional to the data volume of the CSV file to be read
out. Parts are not refreshed until processing is complete. (It
takes approximately 10 seconds to read the data from the first to
the 100th line of a CSV file containing 100 lines, with 40
characters per line.)
-
Unlike the "_CF_read()/_USB_read()"
function, the status is not saved to
[s:CF_ERR_STAT]/[s:USB_ERR_STAT] immediately after the function is
executed. (In some cases, undefined values may be stored.)
-
Be sure to insert ["] at the beginning and
end of text strings that start with a numeral.
For example,
[ 123, 2-D4EA ]
|
[ 123, "2-D4EA" ]
|
×
|
○
|
|