Comma-separated-values are frequently used in my work, as for example Excel (and other modern languages) are very handy at reading them. In Fortran it is not so easy. I try list-directed input, which works "most of the time" but not always. There is trouble when a text value in the input file contains blanks, for example
value-a, value-bcd, value ef, value-ghi
then reading this with
CHARACTER(20) :: str1, str2, str3, str4
READ (5, *) str1, str2, str3, str4
results in
str1 = 'value-a ' [padded with blanks to the declared length of 20]
str2 = 'value-bcd '
str3 = 'value '
str4 = 'ef '
str5 = 'value-ghi'
The result with str3 fails the intent, because the hyphen was accidentally a blank, and blanks are used as value separators for list-directed input (in addition to commas). So, I need an edit descriptor or other formatting method that forces commas to be the ONLY separator. This is easy--indeed automatic--in Excel. My grief is caused because I am handed these files by others who work only with Excel, where they can be careless about inserting blanks in the middle of a string value, and they don't understand the significance of this in Fortran.
Is there a way to reliably read csv files in Fortran that I don't know about?