Summary
Reads data in cell units from a CSV file (constructed from a cell image delimited with ","), and writes it to word addresses.
Format
_CF_read_csv/_SD_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), Device with Offset Specification (Internal Device) (Internal Device + Temporary address, Maximum length is 14 single-byte characters)
Parameter 3: Internal Device, Device with Offset Specification (Internal Device)
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 internal 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).
Error Status
Editor Function Name |
LS Area |
Error Status |
Cause |
---|---|---|---|
_CF_read_csv( ) / _SD_read_csv( ) / _USB_read_csv( ) |
LS9137/ |
0000h |
Completed Successfully |
0001h |
Parameter error |
||
0002h |
External Storage Error No external storage/file open error/file read error |
||
0003h |
Write/Read error |
When writing CSV
file text data to the LS device, the data storage order depends
on the data storage mode. For information about data storage order,
please refer to the following.
22.10.7 Data
Storage Mode
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.
To set the root folder, specify "" (empty string) as the folder name.
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.
When you specify
an internal device for the file name, the file name storage order
is defined by the Text Data Mode.
7.9.1 System
Settings [Device/PLC] Settings Guide
The range of internal devices where you can store data loaded from CSV files is only the 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. (If each line in the CSV file has 40 characters, and with 100 lines, it takes about 10 seconds to load the file from its beginning to the one hundredth line.)
Unlike the "_CF_read()/_SD_read( )/_USB_read()" function, the status is not saved to [s:CF_ERR_STAT]/[s:SD_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" ] |
X |
O |