# How to add a text as .txt file?

**URL:** <https://discourse.processing.org/t/how-to-add-a-text-as-txt-file/40839>\
**Category:** Coding Questions\
**Created:** [February 5, 2023, 8:30pm UTC](https://discourse.processing.org/t/how-to-add-a-text-as-txt-file/40839 "2023-02-05T20:30:46Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Davo](https://avatars.discourse-cdn.com/v4/letter/d/b2d939/32.png) [@Davo](https://discourse.processing.org/u/Davo)\
**Post date:** [February 5, 2023, 8:30pm UTC](https://discourse.processing.org/t/how-to-add-a-text-as-txt-file/40839/1 "2023-02-05T20:30:46Z")

</div>

Hola!

Totally new here. I just want to change the text in this generative design text:

> **[p5.js Web Editor](https://editor.p5js.org/generative-design/sketches/P_3_1_3_02)**
>
> A web editor for p5.js, a JavaScript library with the goal of making coding accessible to artists, designers, educators, and beginners.

How can I change this “faust\_kurz.txt” for my own text and include it as a .txt file?? …Just have no clue…

```auto
function preload() {
  joinedText = loadStrings('data/faust_kurz.txt');

```

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [February 5, 2023, 8:38pm UTC](https://discourse.processing.org/t/how-to-add-a-text-as-txt-file/40839/2 "2023-02-05T20:38:51Z")

</div>

when the file is on your hard drive (make a copy), load it in text editor like Notepad and edit it there and save it with the same name

When the file is not there, make a folder data and therein a text file with the name and put some content in it.

This will also work:

```auto
joinedText = {
  "Hello",
  "Three",
  "Words"
}; 

```

---

<div class="post-metadata">

**Author:** ![Davo](https://avatars.discourse-cdn.com/v4/letter/d/b2d939/32.png) [@Davo](https://discourse.processing.org/u/Davo)\
**Post date:** [February 7, 2023, 8:11am UTC](https://discourse.processing.org/t/how-to-add-a-text-as-txt-file/40839/4 "2023-02-07T08:11:13Z")

</div>

> [@Chrisir](#):
>
> folder data

Thanks a lot for your response! I just want to change the text from that example in the link…

I have no clue of python, and I don’t know where to make a folder data and how to include that inside those code lines in the link.

Also I tried to add the “joinedText” lines, but I don’t know where or how to do it.

I am totally clumsy… Any way to simply change the text in a simple and straight way?

Thank youuuuu

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [February 7, 2023, 8:15am UTC](https://discourse.processing.org/t/how-to-add-a-text-as-txt-file/40839/5 "2023-02-07T08:15:35Z")

</div>

> [@Davo](#):
>
> I just want to change the text from that example in the link…

He’s loading a simple text file in that line. The text in the link is a relative path to a file.

The content of this text file is used.

You can either change the name of the file OR change its content

When you hit ctrl-k you get to your Sketch folder on your hard  
Drive. There you can make (in your windows OS) the folder data and make a text file in it manually.

---

<div class="post-metadata">

**Author:** ![Davo](https://avatars.discourse-cdn.com/v4/letter/d/b2d939/32.png) [@Davo](https://discourse.processing.org/u/Davo)\
**Post date:** [February 7, 2023, 8:44am UTC](https://discourse.processing.org/t/how-to-add-a-text-as-txt-file/40839/6 "2023-02-07T08:44:33Z")

</div>

Thank you so much for the quick response…

But I am in Mac and this ctrl-k shortcut doesn’t work.  
Do you mean that I can have a .txt file in my Mac, and substitute the `data/faust_kurz.txt` for the path of my file?

In that case, what format should that path have? I just tried several forms like “/Users/david/Desktop/text.txt”, my file is in my desktop, but the p5.js editor says:

```auto
Error: [object ReadableStream]
    at [47]</i.prototype.httpDo/f< (https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.2/p5.min.js:10:19644)

```

I just want to change the .txt from this [p5.js Web Editor](https://editor.p5js.org/generative-design/sketches/P_3_1_3_02)

But I really cannot manage, what format should my path to the file have? Is there other way?

I really need to solve this, thank you so much in advance

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [February 7, 2023, 8:58am UTC](https://discourse.processing.org/t/how-to-add-a-text-as-txt-file/40839/7 "2023-02-07T08:58:00Z")

</div>

Ah okay, sorry, p5.js here

So you are in your browser

So you don’t have a file and the Sketch terminates there ?

I think you can add files on the side menu on the right

---

<div class="post-metadata">

**Author:** ![Davo](https://avatars.discourse-cdn.com/v4/letter/d/b2d939/32.png) [@Davo](https://discourse.processing.org/u/Davo)\
**Post date:** [February 7, 2023, 9:33am UTC](https://discourse.processing.org/t/how-to-add-a-text-as-txt-file/40839/8 "2023-02-07T09:33:03Z")

</div>

> [@Davo](#):
>
> ` joinedText`

Wow… I am really trying everything to upload a .txt file … or … I just don’t know how to do it and what to do or how to proceed

---

<div class="post-metadata">

**Author:** ![Davo](https://avatars.discourse-cdn.com/v4/letter/d/b2d939/32.png) [@Davo](https://discourse.processing.org/u/Davo)\
**Post date:** [February 7, 2023, 9:35am UTC](https://discourse.processing.org/t/how-to-add-a-text-as-txt-file/40839/9 "2023-02-07T09:35:39Z")

</div>

How do I change a text or a pic from this string?

```auto
function preload() {
  img = loadImage('data/pic.png');

```

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [February 7, 2023, 9:50am UTC](https://discourse.processing.org/t/how-to-add-a-text-as-txt-file/40839/10 "2023-02-07T09:50:06Z")

</div>

> [@Davo](#):
>
> just want to change the text in this generative design text

Hello @Davo ,

Assuming you are working in the p5.js editor:

> **[p5.js Web Editor](https://editor.p5js.org/)**
>
> A web editor for p5.js, a JavaScript library with the goal of making coding accessible to artists, designers, educators, and beginners.

Steps I followed:

- Login in. If you do not have an account then create one and log in.

- Open this sketch:  
[https://editor.p5js.org/generative-design/sketches/P\_3\_1\_3\_02](https://editor.p5js.org/generative-design/sketches/P_3_1_3_02)

- Expand the _File_ menu (down arrow) and select _duplicate_  
You now have a copy to work with!  
Work with that from this point on…

- Expand the menu next to sketch name (arrow pointing to right):  
Before:  

- Make sure you are always working with your copy from this point on.

- Hover your mouse over the _data_ folder and another arrow appears pointing down!  
Expand that and you will see:  

- I was not able to edit _fast\_kurtx.txt_  
I was able to _Create file_ called _text.txt_ and edit that.  
I could rename _fast\_kurtx.txt_ but was not able to edit so created new file.

- You can also _Upload file_, _Rename_, etc.

That should get you started.

It is a challenge at first to navigate those menus!

There may be a good tutorial or video out there… see what a Google search comes up with and share.

`:)`

---

<div class="post-metadata">

**Author:** ![Davo](https://avatars.discourse-cdn.com/v4/letter/d/b2d939/32.png) [@Davo](https://discourse.processing.org/u/Davo)\
**Post date:** [February 7, 2023, 10:07am UTC](https://discourse.processing.org/t/how-to-add-a-text-as-txt-file/40839/11 "2023-02-07T10:07:05Z")

</div>

Ohhhh…  
That is sooooo nice

THANK YOU for taking the time and the calm to explain it to me.  
I will try it during the day and hopefully make it work.

Have a nice day

---

<div class="post-metadata">

**Author:** ![Davo](https://avatars.discourse-cdn.com/v4/letter/d/b2d939/32.png) [@Davo](https://discourse.processing.org/u/Davo)\
**Post date:** [February 7, 2023, 10:21am UTC](https://discourse.processing.org/t/how-to-add-a-text-as-txt-file/40839/12 "2023-02-07T10:21:03Z")

</div>

IT WORKED!!!  
it’s so easy once I followed your step by step expanation.

You really made my day, please feel during this day that somewhere near Dresden (Germany) someone will have a great day because of you

Thank you again
