encoding.csv: add a new utility fn new_reader_from_file/2 (#20530)

This commit is contained in:
koplenov 2024-01-14 20:42:01 +03:00 committed by GitHub
parent 2f58ac3866
commit 43b8cc8ab7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 0 deletions

12
vlib/encoding/csv/utils.v Normal file
View file

@ -0,0 +1,12 @@
// Copyright (c) 2019-2024 Alexander Medvednikov. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
module csv
import os
// new_reader_from_file create a csv reader from a file
pub fn new_reader_from_file(csv_file_path string, config ReaderConfig) !&Reader {
csv_file_content := os.read_file(csv_file_path)!
return new_reader(csv_file_content, config)
}