Read from SD Card

 1'''
 2SDCard - Read from SD Card.py.
 3
 4This example demonstrates how to read from txt file.
 5
 6For other examples please check:
 7    https://github.com/WPC-Systems-Ltd/WPC_Stand-alone_Python_release/tree/main/examples
 8
 9Copyright (c) 2024 WPC Systems Ltd.
10All rights reserved.
11'''
12
13import pywpc_sd
14
15## Initialize the SD card
16dev = pywpc_sd.SDCard()
17
18## Debug print SD card directory and files
19print(dev.getFileDirectory())
20
21## Open the file in "read mode".
22## Read the file and print the text on debug port.
23file = dev.openFile("sample.txt","r")
24
25if file != 0:
26    print("Reading from SD card")
27    print (dev.readFile())
28
29## Close the file
30dev.closeFile()