libsim Versione 7.2.6
|
◆ csv_record_init()
Initialise a csv_record object. If the record is provided in input, the object is used for decoding a record read from a file (csv_record_getfield methods), if record is not provided, then the object will be used for coding a csv record (csv_record_addfield methods), for the successive write on file. It is possible to specify nonstandard characters for delimiting and grouping fields, default comma (,) and double quote ("). In case of decoding, it is possible to obtain in output the number of fields in the record, but this will take extra computing time. As an alternative, the ::csv_record_end method can be used when extracting each field. Warning: the \a csv_record class does not handle csv records that extend on different lines. @param [in,out] this object to be initialised @param [in] record csv record to be interpreted, if not provided, it means we want to code a csv record for output @param [in] csep field separator character, default \c , (comma) @param [in] cquote field grouping character, default \c " (double quote); it is usually used when a field contains comma or blanks
Definizione alla linea 487 del file file_utilities.F90. 488
489
490!> Add a field from a \c REAL variable to the csv record \a this.
491!! The field will be quoted if necessary.
492SUBROUTINE csv_record_addfield_real(this, field, form, force_quote)
493TYPE(csv_record),INTENT(INOUT) :: this !< object where to add field
494REAL,INTENT(IN) :: field !< field to be added
495CHARACTER(len=*),INTENT(in),OPTIONAL :: form !< optional format
496LOGICAL, INTENT(in), OPTIONAL :: force_quote !< if provided and \c .TRUE. , the field will be quoted even if not necessary
497
498IF (PRESENT(form)) THEN
499 CALL csv_record_addfield(this, trim(to_char(field, form)), force_quote=force_quote)
500ELSE
501 CALL csv_record_addfield(this, t2c(field), force_quote=force_quote)
502ENDIF
503
504END SUBROUTINE csv_record_addfield_real
505
506
507!> Add a field from a \c REAL variable to the csv record \a this.
508!! The field will be quoted if necessary. A missing value is inserted
509!! as an empty field.
510SUBROUTINE csv_record_addfield_real_miss(this, field, force_quote)
511TYPE(csv_record),INTENT(INOUT) :: this !< object where to add field
512REAL,INTENT(IN) :: field !< field to be added
513LOGICAL, INTENT(in), OPTIONAL :: force_quote !< if provided and \c .TRUE. , the field will be quoted even if not necessary
514
515CALL csv_record_addfield(this, t2c(field, ''), force_quote=force_quote)
516
517END SUBROUTINE csv_record_addfield_real_miss
518
519
520!> Add a field from a \c DOUBLE PRECISION variable to the csv record \a this.
521!! The field will be quoted if necessary.
522SUBROUTINE csv_record_addfield_double(this, field, form, force_quote)
523TYPE(csv_record),INTENT(INOUT) :: this !< object where to add field
524DOUBLE PRECISION,INTENT(IN) :: field !< field to be added
525CHARACTER(len=*),INTENT(in),OPTIONAL :: form !< optional format
|