Personal tools
You are here: Home CDAT Tips and Tricks File I/O Tips Printing to an ASCII File
Document Actions

Printing to an ASCII File

In this tutorial we show how to write data to an ascii file

  Table of Contents Previous Next
Contents Previous Next

Goal: Learn how to print data to an ASCII file in CDAT.

# First open the ascii file
# Note we do NOT use the cdms.open here!

f=open('text.txt','w')

# Now writing to the file works just like writing to the screen

print >> f, '# Example file to write data to it'

# At the end do not forget to close the file
f.close()
  Table of Contents Previous Next
Contents Previous Next

Powered by Plone