add option to save generated code into fileSee original GitHub issue
I’m sorry if I missed this functionality, but
CLI version hasn’t it for sure (I saw the related code only in
generate_code_examples.py). I guess it will be very useful to eliminate copy-paste phase, especially for large models.
Of course, piping is a solution, but not for development in Jupyter Notebook, for example.
- Created 4 years ago
- Comments:9 (6 by maintainers)
Top GitHub Comments
If you’re using
m2cgen in CLI you can just redirect its
stdout into the file. Eg:
$ m2cgen <path_to_model> --language c > <path_to_output_file>
Alternatively if you’re using the Python API:
import m2cgen as m2c generated_code = m2c.export_to_c(...) with open('<path_to_output_file', 'w') as fd: fd.write(generated_code)
Hope this helps!
Closing due to the lack of interest.