Repository navigation
trims zsv related metadata from column names - #7963
jangorecki wants to merge 3 commits into
Conversation
(Plot image upload to picrd.com failed; download the artifact below to view plots) Generated via commit 8f8078b Download link for the artifact containing the test results: ↓ atime-results.zip
|
tdhock
left a comment
There was a problem hiding this comment.
this is interesting! R code looks ok to me. add NEWS item?
|
NEWS entry is there |
tdhock
left a comment
There was a problem hiding this comment.
pleas save fread result in variable to avoid duplication and make code easier to read?
| # zsv format handling | ||
| fwrite(fread(text = "id~u8-index~0~zsv,year~u16-partition{2024@0|2025@30|2026@45},city~str,amount~f64 | ||
| 1,2024,Bern,2.5 | ||
| 2,2024,Basel, | ||
| 4,2025,Zug,1.5 | ||
| 5,2026,Bern,3"), zsv<-tempfile(fileext=".zsv")) | ||
| test(2390.01, names(fread(zsv)), c("id","year","city","amount")) | ||
| fwrite(fread(text = "id~u8-index~0~csv,year~u16-partition{2024@0|2025@30|2026@45},city~str,amount~f64 | ||
| 1,2024,Bern,2.5 | ||
| 2,2024,Basel, | ||
| 4,2025,Zug,1.5 | ||
| 5,2026,Bern,3"), csv<-tempfile(fileext=".csv")) |
There was a problem hiding this comment.
| # zsv format handling | |
| fwrite(fread(text = "id~u8-index~0~zsv,year~u16-partition{2024@0|2025@30|2026@45},city~str,amount~f64 | |
| 1,2024,Bern,2.5 | |
| 2,2024,Basel, | |
| 4,2025,Zug,1.5 | |
| 5,2026,Bern,3"), zsv<-tempfile(fileext=".zsv")) | |
| test(2390.01, names(fread(zsv)), c("id","year","city","amount")) | |
| fwrite(fread(text = "id~u8-index~0~csv,year~u16-partition{2024@0|2025@30|2026@45},city~str,amount~f64 | |
| 1,2024,Bern,2.5 | |
| 2,2024,Basel, | |
| 4,2025,Zug,1.5 | |
| 5,2026,Bern,3"), csv<-tempfile(fileext=".csv")) | |
| # zsv format handling | |
| zsv.dt = fread(text = "id~u8-index~0~csv,year~u16-partition{2024@0|2025@30|2026@45},city~str,amount~f64 | |
| 1,2024,Bern,2.5 | |
| 2,2024,Basel, | |
| 4,2025,Zug,1.5 | |
| 5,2026,Bern,3") | |
| fwrite(zsv.dt, zsv<-tempfile(fileext=".zsv")) | |
| test(2390.01, names(fread(zsv)), c("id","year","city","amount")) | |
| fwrite(zsv.dt, csv<-tempfile(fileext=".csv")) |
There was a problem hiding this comment.
change suggested does not match original code, where first case has ~zsv marker vs second ~csv text, which is not proper format marker so is recognized as ordinary column name
There was a problem hiding this comment.
ok I did not notice that, maybe add a comment to emphasize that difference for future readers?
Background: it is possible to push limits of fread when reading from pre-indexed csv.
Reproducible example is taken from: Filter big csv early by partitions in
zsv/README.mdzsv internally is still csv, just longer column names.
This PR trims zsv related metadata from column names when reading such csv directly via
fread("tiny.zsv"):