Показать сообщение отдельно
Старый 26.03.2024, 16:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,477 / 846 (79) +++++++
Регистрация: 28.10.2006
a33ik: Read/Write CSV file
Источник: http://daxonline.org/1945-read-write-csv-file.html
==============

If unquoted text values are required then CommaTextStreamIo should be replaced with TextStreamIo, which has the same methods.

Read CSV file



#File #OCCRetryCount #define.delimiterField(',') System.IO.MemoryStream memoryStream = connector.getCurrentMemoryStream(); CommaTextStreamIo commaTextStreamIo = CommaTextStreamIo::constructForRead(memoryStream); if (commaTextStreamIo) { if (commaTextStreamIo.status()) { throw error("@CLIDocuments:FileUpload_Failed"); } commaTextStreamIo.inFieldDelimiter(#delimiterField); commaTextStreamIo.inRecordDelimiter(#delimiterCRLF); container record; while (!commaTextStreamIo.status()) { record = commaTextStreamIo.read(); } }


Write CSV file

CommaTextStreamIo commaTextStreamIo = CommaTextStreamIo::constructForWrite(); commaTextStreamIo.writeExp(['row 1 col 1', 'row 1 col 2']); commaTextStreamIo.writeExp(['row 2 col 1', 'row 2 col 2']); File::SendFileToUser(commaTextStreamIo.getStream(), 'file name.csv');
Result:






Источник: http://daxonline.org/1945-read-write-csv-file.html