Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a Text File in Julia

Tags:

julia

I have a string

a = """
---
title: Just a test
author: Me
date: 2022-01-03
---

# Test Header 
Some text.
"""

from which I want to create a file foobar.jmd. What is the best way of doing this?

like image 673
Georgery Avatar asked Dec 07 '25 19:12

Georgery


1 Answers

fname = "foobar.jmd"
dirpath = "/tmp"
fpath = joinpath(dirpath, fname)

open(fpath, "w") do file
    write(file, a)
end

More examples e.g. here https://en.wikibooks.org/wiki/Introducing_Julia/Working_with_text_files

like image 200
vasja Avatar answered Dec 12 '25 22:12

vasja