Re: Reading a file line by line at compile time

2019-08-12 Thread cdome
Line by lines is not support at compile time. One more option: readLines("input",3) reads first 3 lines of file, works at compile time. Useful if you need to parse a header in the beginning of the file.

Re: Reading a file line by line at compile time

2019-08-10 Thread jyapayne
Huh, interesting. That works! I was more looking for something that wouldn't read everything into memory at once (kind of like memfiles), but this works for now. Thank you!

Re: Reading a file line by line at compile time

2019-08-09 Thread gemath
Like this: import strutils macro r: untyped = for l in "input".slurp.splitLines: # process a line echo l r() Run

Reading a file line by line at compile time

2019-08-09 Thread jyapayne
Is there a way to read a file line by line at compile time? My use case is that I want to process an input file and produce Nim code via macros, but have no trace of the input file in the resulting binary. Basically, I just want to iterate over the lines and throw them away after the VM has read