Working With Files

When you write Python code in CodeSpace it is stored on your CodeBot’s filesystem. Your Python code can also create, read, and write files of its own.

You’ve probably noticed when you plug your CodeBot in to the USB port of a computer that it shows up as a mass-storage device, like a flash drive. This can be really useful! For example, your Python code can log sensor data to a CSV file, which you can later access with a PC through the USB-attached filesystem.

The filesystem differs between CodeBot CB2 and CB3 models. Please refer to the section below matching your CodeBot.


The CB2’s filesystem is always writable by both the Python code running on CodeBot AND the OS of your PC. Unlike with the CB3 and CodeX, you don’t have to do anything special to enable this capability.

  • For example, you can copy files to and from the CodeBot from your PC filesystem;

  • Or you can use an external text editor to edit Python code on the CodeBot…

However, a drawback of this is that the PC can corrupt the FLASH filesystem on the CodeBot if the internal Python code changes something “behind its back” such that the PC becomes confused. After all, normal “flash drives” don’t change files by themselves while they’re plugged-in!

  • After copying files to the CodeBot mass-storage, test it by ejecting and reinserting the USB to confirm your files persist.

  • If the filesystem does become corrupted it’s no big deal. Just follow the instructions to Reformat CodeBot’s Filesystem.


By default the CB3’s USB-accessible filesystem is read-only, so a PC can’t for example copy new Python files to it, or edit existing ones. But if you want to do such things, there’s a way to change it so the filesystem can be written to “like a flash drive”. Note that while it’s in this mode your Python code (and CodeSpace) will see the filesystem as read-only. You can’t have it writable from both directions.

The following bootup button-combination will make the filesystem writable as a USB mass-storage device until the next reset of CodeBot.

  1. Press and hold button-1 and keep holding it down

  2. Briefly press and release the RESET button.

  3. Keep holding button-1 until you hear a short tone from the speaker. Release button-1 immediately!

  4. You will hear a 2-beep confirmation tone to confirm the filesystem is in USB-writable mode.