mirror of
https://github.com/vlang/v.git
synced 2025-09-14 23:12:33 +03:00
fmt: fix alignment of struct init fields (#22025)
This commit is contained in:
parent
99da5726db
commit
c51d30bf53
671 changed files with 18817 additions and 18787 deletions
|
@ -259,7 +259,7 @@ import encoding.csv
|
|||
fn main() {
|
||||
file_path := 'big2.csv'
|
||||
mut csvr := csv.csv_reader(
|
||||
file_path: file_path // path to the file CSV
|
||||
file_path: file_path // path to the file CSV
|
||||
mem_buf_size: 1024 * 1024 * 64 // we set 64MByte of buffer for this file
|
||||
end_line_len: csv.endline_crlf_len // we are using a windows text file
|
||||
)!
|
||||
|
@ -295,9 +295,9 @@ a,b,c
|
|||
|
||||
fn main() {
|
||||
mut csvr := csv.csv_reader(
|
||||
scr_buf: txt.str
|
||||
scr_buf: txt.str
|
||||
scr_buf_len: txt.len
|
||||
comment: `#` // line starting with # will be ignored
|
||||
comment: `#` // line starting with # will be ignored
|
||||
)!
|
||||
// scan all rows, csvr.csv_map.len contain the valid
|
||||
// rows number in the CSV file.
|
||||
|
@ -328,10 +328,10 @@ const txt = "
|
|||
|
||||
fn main() {
|
||||
mut csvr := csv.csv_reader(
|
||||
scr_buf: txt.str // string pointer
|
||||
scr_buf_len: txt.len // string length
|
||||
comment: `#` // line starting with # will be ignored
|
||||
quote: `'` // char used for quotes
|
||||
scr_buf: txt.str // string pointer
|
||||
scr_buf_len: txt.len // string length
|
||||
comment: `#` // line starting with # will be ignored
|
||||
quote: `'` // char used for quotes
|
||||
quote_remove: true // remove quotes from the cells
|
||||
)!
|
||||
|
||||
|
@ -351,4 +351,4 @@ Output:
|
|||
['4', '5', 'a,b,c', 'e']
|
||||
```
|
||||
## Performance
|
||||
This module was tested with CSV files up to 4 GBs with 4 million rows
|
||||
This module was tested with CSV files up to 4 GBs with 4 million rows
|
|
@ -460,9 +460,9 @@ pub fn (mut cr RandomAccessReader) build_header_dict(cfg GetHeaderConf) ! {
|
|||
// fill the base struct
|
||||
label := cr.get_cell(x: col, y: cfg.header_row)!
|
||||
mut h := HeaderItem{
|
||||
label: label
|
||||
label: label
|
||||
column: col
|
||||
htype: .string
|
||||
htype: .string
|
||||
}
|
||||
|
||||
// try to infer the type if we haev at least one more row
|
||||
|
|
|
@ -38,39 +38,39 @@ a,"b,c,d",0,#,3,"pippo"
|
|||
|
||||
const target_header_list = [
|
||||
csv.HeaderItem{
|
||||
label: 'a'
|
||||
label: 'a'
|
||||
column: 0
|
||||
htype: .int
|
||||
htype: .int
|
||||
},
|
||||
csv.HeaderItem{
|
||||
label: 'b'
|
||||
label: 'b'
|
||||
column: 1
|
||||
htype: .string
|
||||
htype: .string
|
||||
},
|
||||
csv.HeaderItem{
|
||||
label: 'c'
|
||||
label: 'c'
|
||||
column: 2
|
||||
htype: .f32
|
||||
htype: .f32
|
||||
},
|
||||
csv.HeaderItem{
|
||||
label: 'd'
|
||||
label: 'd'
|
||||
column: 3
|
||||
htype: .f32
|
||||
htype: .f32
|
||||
},
|
||||
csv.HeaderItem{
|
||||
label: 'e'
|
||||
label: 'e'
|
||||
column: 4
|
||||
htype: .int
|
||||
htype: .int
|
||||
},
|
||||
csv.HeaderItem{
|
||||
label: 'f'
|
||||
label: 'f'
|
||||
column: 5
|
||||
htype: .string
|
||||
htype: .string
|
||||
},
|
||||
csv.HeaderItem{
|
||||
label: 'g'
|
||||
label: 'g'
|
||||
column: 6
|
||||
htype: .int
|
||||
htype: .int
|
||||
},
|
||||
]
|
||||
|
||||
|
@ -146,7 +146,7 @@ fn test_csv_sequential() {
|
|||
f.close()
|
||||
|
||||
csvr = csv.csv_sequential_reader(
|
||||
file_path: file_path_str
|
||||
file_path: file_path_str
|
||||
mem_buf_size: 64
|
||||
end_line_len: csv.endline_crlf_len
|
||||
)!
|
||||
|
@ -267,7 +267,7 @@ fn test_csv_string() {
|
|||
|
||||
// parse the temp file
|
||||
csvr = csv.csv_reader(
|
||||
file_path: file_path_str
|
||||
file_path: file_path_str
|
||||
mem_buf_size: 32
|
||||
end_line_len: csv.endline_crlf_len
|
||||
)!
|
||||
|
@ -283,8 +283,8 @@ fn test_csv_string() {
|
|||
|
||||
// test crlf endline
|
||||
csvr = csv.csv_reader(
|
||||
scr_buf: txt3.str
|
||||
scr_buf_len: txt3.len
|
||||
scr_buf: txt3.str
|
||||
scr_buf_len: txt3.len
|
||||
end_line_len: csv.endline_crlf_len
|
||||
)!
|
||||
perform_test3(mut csvr)!
|
||||
|
@ -321,7 +321,7 @@ fn test_coherence() {
|
|||
|
||||
// parse the temp file
|
||||
mut csvr := csv.csv_reader(
|
||||
file_path: file_path_str
|
||||
file_path: file_path_str
|
||||
mem_buf_size: 32
|
||||
end_line_len: csv.endline_cr_len
|
||||
)!
|
||||
|
|
|
@ -61,9 +61,9 @@ pub:
|
|||
// optionally, a custom delimiter.
|
||||
pub fn new_reader(data string, config ReaderConfig) &Reader {
|
||||
return &Reader{
|
||||
data: data
|
||||
data: data
|
||||
delimiter: config.delimiter
|
||||
comment: config.comment
|
||||
comment: config.comment
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ pub:
|
|||
// new_writer returns a reference to a Writer
|
||||
pub fn new_writer(config WriterConfig) &Writer {
|
||||
return &Writer{
|
||||
sb: strings.new_builder(200)
|
||||
use_crlf: config.use_crlf
|
||||
sb: strings.new_builder(200)
|
||||
use_crlf: config.use_crlf
|
||||
delimiter: config.delimiter
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue