Skip to content

First array entry skipped when adding from array #9

Closed
@jg110

Description

@jg110

If csv_write_test.f90 is modified to construct an input array from array values, the first entry is ignored:

program csv_write_test

use csv_module
use iso_fortran_env, only: wp => real64

implicit none

type(csv_file) :: f
logical :: status_ok
real(wp), dimension(3) :: X = [1._wp, 2._wp, 3._wp]

! open the file
call f%open('test.csv',n_cols=4,status_ok=status_ok)

! add header
call f%add(['x','y','z','t'])
call f%next_row()

! add some data:
call f%add([X(1),X(2),X(3)],real_fmt='(F5.3)')
call f%add(.true.)
call f%next_row()
call f%add([4.0_wp,5.0_wp,6.0_wp],real_fmt='(F5.3)')
call f%add(.false.)
call f%next_row()

! finished
call f%close(status_ok)

end program csv_write_test

test.csv:

"x","y","z","t"
2.000,3.000,0.000,T
4.000,5.000,6.000,F

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions