Skip to content

Commit 9fe51ad

Browse files
committed
- Adding "SourceFile" as last element of headers
- Setting this element to the appropriate filename in the output directory to distinguish between records.
1 parent 001f7a8 commit 9fe51ad

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

helpers/helpers.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,13 @@ func CombineOutputs(arguments map[string]any, logger zerolog.Logger) error {
469469
logger.Error().Msg(err.Error())
470470
continue
471471
}
472+
473+
headers = append(headers, "SourceFile")
474+
472475
writer := csv.NewWriter(outputF)
476+
473477
writer.Write(headers)
474-
// Now we have created an output CSV and written the headers from the first file to it - for each file we will kick off a gorroutine that will read and send records to the writer channel
478+
// Now we have created an output CSV and written the headers from the first file to it - for each file we will kick off a goroutine that will read and send records to the writer channel
475479
// Once all readers are done, the waitgroup will be done and the per-file channel will be closed
476480
// Once all per-file channels are closed, are independent writers will finish and signal that the main wait group is done and we can proceed with execution
477481

@@ -636,6 +640,8 @@ func readAndSendToChannel(csvFile string, c chan []string, waiter *lbtypes.WaitG
636640
continue
637641
}
638642
record = resortRecord(record, newIndexOrder, initialHeaders)
643+
// Setting last element of record to the SourceFile column so we can understand which results come from which files when combining results
644+
record[len(initialHeaders)-1] = csvFile
639645
c <- record
640646
}
641647
}

0 commit comments

Comments
 (0)