Created
March 20, 2023 14:46
-
-
Save rccc/8b71bbbc735794d6617a64517833df41 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import encoding.csv | |
fn main(){ | |
csv_name := 'test.csv' | |
content := os.read_file(csv_name) or {panic(err)} | |
mut reader := csv.new_reader(content) | |
reader.read()! // Skip the first line | |
for { | |
line := reader.read() or {break} | |
println(line) | |
} | |
} |
Quickly looking at the code of the CVS module, the break should not be alone. There should be a check for the kind of error, and only break if it is "EndOfFileError", otherwise the error should be passed up. The test code does not do it, but it is not good practice - it may be ok for testing but should not be in prod. Have fun. Never used the code so good luck!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
not tested: