source: trunk/anuga_core/source/anuga/file/test_csv.py @ 7762

Last change on this file since 7762 was 7762, checked in by hudson, 14 years ago

All tests in file module pass.

File size: 1.0 KB
Line 
1import os
2import unittest
3import tempfile
4import numpy as num
5
6from csv_file import load_csv_as_array, load_csv_as_dict
7
8
9class Test_csv(unittest.TestCase):
10    def setUp(self):
11        pass
12
13    def tearDown(self):
14        pass
15       
16    def test_get_data_from_file1(self):
17        fileName = tempfile.mktemp(".txt")
18#        print"filename",fileName
19        file = open(fileName,"w")
20        file.write("elevation stage\n\
211.3 3  \n\
220.0 4 \n\
234.5 3.5 \n\
241.0 6 \n")
25        file.close()
26
27        x = load_csv_as_array(fileName, delimiter=' ') 
28       
29       # header, x = load_csv_as_array(fileName, delimiter=' ')
30        os.remove(fileName)
31
32        assert num.allclose(x['elevation'], [1.3, 0.0,4.5, 1.0])
33        assert num.allclose(x['stage'], [3.0, 4.0,3.5, 6.0])       
34       
35
36#################################################################################
37
38if __name__ == "__main__":
39    suite = unittest.makeSuite(Test_csv, 'test')
40    runner = unittest.TextTestRunner(verbosity=1)
41    runner.run(suite)
Note: See TracBrowser for help on using the repository browser.