File: sample_data_test.py

package info (click to toggle)
matplotlib 1.1.1~rc2-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 66,076 kB
  • sloc: python: 90,600; cpp: 69,891; objc: 5,231; ansic: 1,723; makefile: 171; sh: 7
file content (26 lines) | stat: -rw-r--r-- 667 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""
Demonstrate how get_sample_data works with git revisions in the data.

    git clone git@github.com/matplotlib/sample_data.git

and edit testdata.csv to add a new row.  After committing the changes,
when you rerun this script you will get the updated data (and the new
git version will be cached in ~/.matplotlib/sample_data)
"""

import matplotlib.mlab as mlab
import matplotlib.cbook as cbook

# get the file handle to the cached data and print the contents
datafile = 'testdir/subdir/testsub.csv'
fh = cbook.get_sample_data(datafile)
print fh.read()

# make sure we can read it using csv2rec
fh.seek(0)
r = mlab.csv2rec(fh)

print mlab.rec2txt(r)

fh.close()