Opening data file.
![]() |
![]() |
![]() | |
| Contents | Previous | Next |
Goal: Learn how to open a file in CDAT.
Opening file syntax:
fileobj = cdms.open(String path, String mode)Open the file specified by path returning a CdmsFile object.
path is the file pathname, a string.
mode is the open mode indicator, as listed in the table below:
| 'r' |
read - only |
| 'r+' |
read-write |
| 'a' |
read-write. Open the file if it exists, otherwise create a new file. |
| 'w' |
create a new file, read-write. |
Opening a self-describing file for reading
import cdmsIt will open an existing file protected against writing
f = cdms.open(file_name)
Opening a new file for writing
f = cdms.open(file_name,’w’)
It will create a new file even if it already exists
Opening an existing file for writing
f = cdms.open(file_name,’r+’) # or‘a’
It will open an existing file ready for writing or reading
![]() |
![]() |
![]() | |
| Contents | Previous | Next |


