From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e8077541d594b377 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed01.chello.at!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: CSV package in Ada Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: Date: Sun, 25 Mar 2007 10:41:01 +0200 Message-ID: <1cys02tpeum2j$.1rndvnxqpgq66$.dlg@40tude.net> NNTP-Posting-Date: 25 Mar 2007 10:40:43 CEST NNTP-Posting-Host: 61a0054c.newsspool3.arcor-online.net X-Trace: DXC=9VjSTfEkCgePKPPVf;4hUjMcF=Q^Z^V3h4Fo<]lROoRaFl8W>\BH3YbYd@RMg7c3ldZSLZAm X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:14635 Date: 2007-03-25T10:40:43+02:00 List-Id: On Sat, 24 Mar 2007 19:57:59 +0100, Franz Kruse wrote: > Does somebody know of an Ada package/library that can read and write CSV > encoded text? CSV = comma-separated values? http://www.dmitry-kazakov.de/ada/strings_edit.htm which can read and write numbers and quoted strings skipping or placing separators between them. The procedures that take something from the string are named Get, the procedures that put something are named Put. When reading a file, you read it line by line. For each line you set the cursor (the string index) to the first character of and then call Get for each field. To skip spaces and tabs another Get is called. Each call to a Get advances the cursor until the whole line is done. Then you read the next line. Writing is similar, you use Put for the line (string buffer) and after the last field has been written, the buffer slice (Line'First..Cursor-1) is sent the file. For dealing with text literals (non-quoted strings) you can use tables: http://www.dmitry-kazakov.de/ada/tables.htm a table will define the set of literals like (Red, Blue, Green) of a field. The table can be matched against the string the same way the Get programs from Strings_Edit do. The table Get finds a token and skips it in the string returning the value associated with the token. If you need dimensioned values in the fields, see http://www.dmitry-kazakov.de/ada/units.htm which supports the same technique of Get/Put. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de