1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

encoding.csv: allow passing a custom delimiter to the new_reader function (#13910)

This commit is contained in:
StunxFS
2022-04-03 12:13:43 -04:00
committed by GitHub
parent 782d5374c9
commit 38853568b4
2 changed files with 39 additions and 4 deletions

View File

@ -50,12 +50,19 @@ pub mut:
row_pos int
}
// new_reader initializes a Reader with string data to parse
pub fn new_reader(data string) &Reader {
[params]
pub struct ReaderConfig {
delimiter byte = `,`
comment byte = `#`
}
// new_reader initializes a Reader with string data to parse and,
// optionally, a custom delimiter.
pub fn new_reader(data string, config ReaderConfig) &Reader {
return &Reader{
delimiter: `,`
comment: `#`
data: data
delimiter: config.delimiter
comment: config.comment
}
}