Skip to content

Commit

Permalink
Merge pull request #44 from RJaBi/master
Browse files Browse the repository at this point in the history
Set delimiter when reading csv
  • Loading branch information
jacobwilliams authored Dec 29, 2024
2 parents 7357ca4 + 864baee commit 411fd77
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/csv_module.F90
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ end subroutine destroy_csv_file
!>
! Read a CSV file.

subroutine read_csv_file(me,filename,header_row,skip_rows,status_ok)
subroutine read_csv_file(me,filename,header_row,skip_rows,status_ok,delimiter)

implicit none

Expand All @@ -208,6 +208,8 @@ subroutine read_csv_file(me,filename,header_row,skip_rows,status_ok)
logical,intent(out) :: status_ok !! status flag
integer,intent(in),optional :: header_row !! the header row
integer,dimension(:),intent(in),optional :: skip_rows !! rows to skip
character(len=1),intent(in),optional :: delimiter !! note: can only be one character
!! (Default is `,`)

type(csv_string),dimension(:),allocatable :: row_data !! a tokenized row
integer,dimension(:),allocatable :: rows_to_skip !! the actual rows to skip
Expand All @@ -230,6 +232,7 @@ subroutine read_csv_file(me,filename,header_row,skip_rows,status_ok)
arrays_allocated = .false.
if (allocated(me%csv_data)) deallocate(me%csv_data)
if (allocated(me%header)) deallocate(me%header)
if (present(delimiter)) me%delimiter = delimiter

open(newunit=iunit, file=filename, status='OLD', iostat=istat)

Expand Down

0 comments on commit 411fd77

Please sign in to comment.