Differences between revisions 1 and 4 (spanning 3 versions)
Revision 1 as of 2008-04-16 17:33:36
Size: 108
Editor: anonymous
Comment:
Revision 4 as of 2008-04-16 17:52:48
Size: 904
Editor: anonymous
Comment:
Deletions are marked like this. Additions are marked like this.
Line 6: Line 6:

<<TableOfContents(2)>>

= Input/Output =

This lesson deals with the ways of reading and writing data

== Basic Python ==
The [[http://docs.python.org/lib/bltin-file-objects.html|file object]] can be used for reading and
writing plain text as well as unformatted binary data. The following code
writes a message in the file with the name ''out.txt'', reads and print the data
{{{#!python
file('out.txt','w').write('Hallo Datentraeger')
print file('out.txt').read()
}}}

 * {{{write()}}} writes a string to the file
 * {{{read()}}} reads complete file
 * {{{read(N)}}} reads N bytes
 * {{{readlines()}}} reads the file with linebreaks
 * {{{readline()}}} reads only the next line



== NumPy/SciPy ==

== HDF ==

== netCDF ==

== Various Satellite data formats ==

SiaProgrammingPython

Input/Output

This lesson deals with the ways of reading and writing data

Basic Python

The file object can be used for reading and writing plain text as well as unformatted binary data. The following code writes a message in the file with the name out.txt, reads and print the data

   1 file('out.txt','w').write('Hallo Datentraeger')
   2 print file('out.txt').read()
  • write() writes a string to the file

  • read() reads complete file

  • read(N) reads N bytes

  • readlines() reads the file with linebreaks

  • readline() reads only the next line

NumPy/SciPy

HDF

netCDF

Various Satellite data formats

LehreWiki: SiaProgrammingPythonIo (last edited 2008-04-21 12:10:37 by anonymous)