This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: read CSV data consistently from string or file
- From: Jerry DeLisle <jvdelisle at charter dot net>
- To: "Browning, Robert S IV ERDC-RDE-GSL-MS CIV" <Robert dot S dot Browning at erdc dot dren dot mil>, "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>
- Date: Fri, 12 Oct 2018 16:52:54 -0700
- Subject: Re: read CSV data consistently from string or file
- References: <10B680D9-A65E-4B86-9F7C-760184201DAB@contoso.com> <0A2AF1BD-224D-4EC7-BD4C-52CEBBDAF1AF@erdc.dren.mil> <80D3D374-24CC-4283-BDDC-6355F0E05AC6@erdc.dren.mil>
On 10/12/18 1:10 PM, Browning, Robert S IV ERDC-RDE-GSL-MS CIV wrote:
I am needing to read in a text file that contains numerical data separated by keywords. Because of the keywords, I need to read each line in as text first and test if it’s a keyword, and then call the appropriate subroutine based on the keyword value. Within the subroutines I also need to read each line as text first so I can stop the subroutine when the next keyword is found.
The numerical data can be in either fixed format or comma-separated-value (CSV) format. In the CSV data, a zero could be represented by a pair of commas with no number between them.
The issue I have encountered is that the read statement appears to behave differently when it is reading from a character string than when it is reading directly from the input file. If I were able to read directly from the input file, then a simple formatted read statement does everything I need. But if I am reading from a string, then things get a bit more complicated.
Hi Robert,
This may be a known bug. It sounds familiar. Let me do some checking.
Fortranners, if I confirm this is the bug I think it is, I think I can
squeeze some time to fix it.
Jerry