Skip to content

Commit 411fd77

Browse files
Merge pull request #44 from RJaBi/master
Set delimiter when reading csv
2 parents 7357ca4 + 864baee commit 411fd77

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/csv_module.F90

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ end subroutine destroy_csv_file
199199
!>
200200
! Read a CSV file.
201201

202-
subroutine read_csv_file(me,filename,header_row,skip_rows,status_ok)
202+
subroutine read_csv_file(me,filename,header_row,skip_rows,status_ok,delimiter)
203203

204204
implicit none
205205

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

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

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

0 commit comments

Comments
 (0)