sdcard#
loadfile()#
The loadfile(filename, buffer) method loads the named file. If the optional bytearray is None, then an empty file is created.
Parameters |
Description |
|---|---|
|
The name of the file to read. |
|
Optional. A bytearray to read the file into. |
Returns: A bytearray with the file data.
# Read the file into new bytearray.
b = brain.sdcard.loadfile('MyTextFile.txt')
is_inserted()#
The is_inserted() method returns the status of the SD Card.
Returns: True if an SD card is inserted into the brain. False if it is not.
filesize()#
The filesize(filename) method returns the size in bytes of the named file.
Parameters |
Description |
|---|---|
|
The name of the file to check. |
Returns: The size of file in bytes.
savefile()#
The savefile(filename, buffer) method saves a bytearray into a named file. If the optional bytearray is None, then an empty file is created.
Parameters |
Description |
|---|---|
|
The name of the file to write. |
|
Optional. A bytearray to write into the file. |
Returns: The number of bytes written.
# Write the bytearray into a file.
brain.sdcard.savefile('MyTextFile.txt', bytearray("Hello "))
appendfile()#
The appendfile(filename, buffer) method appends a bytearray into a named file. Append is used to add more data to an existing file.
Parameters |
Description |
|---|---|
|
The name of the file to write. |
|
A bytearray to write into the file. |
Returns: The number of bytes written.
# Append the bytearray into a file.
brain.sdcard.appendfile('MyTextFile.txt', bytearray("World "))
size()#
The size(filename) method returns the size in bytes of the named file.
Parameters |
Description |
|---|---|
|
The name of the file to check. |
Returns: The size of file in bytes.
exists()#
The exists(filename) method checks to see if the named file exists on the sd card.
Parameters |
Description |
|---|---|
|
The name of the file to check. |
Returns: True if file exists. False if it does not exist.