コード例 #1
0
    def test_read_csv(self):
        raw_data = "id,first_name,last_name,age,preTestScore,postTestScore\n0,Jason,Miller,42,4,\"25,000\"\n"
        file_out = StringIO(raw_data)
        file_in = StringIO()

        df = read_csv(file_out, index_col='id')
        df.to_csv(file_in)

        self.assertEqual(file_in.getvalue(), raw_data)

        raw_data = "time,first_name,last_name,age,preTestScore,postTestScore\n1981-01-01,Jason,Miller,42,4,\"25,000\"\n"
        file_out = StringIO(raw_data)
        file_in = StringIO()

        df = read_csv(file_out, index_col='time')
        df.to_csv(file_in)

        self.assertEqual(file_in.getvalue(), raw_data)
コード例 #2
0
ファイル: test_io.py プロジェクト: CCI-Tools/ect-core
    def test_read_csv(self):
        raw_data = "id,first_name,last_name,age,preTestScore,postTestScore\n0,Jason,Miller,42,4,\"25,000\"\n"
        file_out = StringIO(raw_data)
        file_in = StringIO()

        df = read_csv(file_out, index_col='id')
        df.to_csv(file_in)

        self.assertEqual(file_in.getvalue(), raw_data)

        raw_data = "time,first_name,last_name,age,preTestScore,postTestScore\n1981-01-01,Jason,Miller,42,4,\"25,000\"\n"
        file_out = StringIO(raw_data)
        file_in = StringIO()

        df = read_csv(file_out, index_col='time')
        df.to_csv(file_in)

        self.assertEqual(file_in.getvalue(), raw_data)
コード例 #3
0
    def test_read_csv_as_geo_data_frame(self):
        raw_data = "lat,lon,time,value,name\n" + \
                   "50.0,10.2,2020-02-08T11:40:53Z,234.3,Loc 1\n" + \
                   "52.5,11.2,2020-02-08T11:41:27Z,165.0,Loc 2\n" + \
                   "51.3,12.1,2020-02-08T11:42:12Z,198.4,Loc 3\n" + \
                   "53.9,10.8,2020-02-08T11:43:26Z,210.5,Loc 4"

        df = read_csv(StringIO(raw_data))

        self.assertIsInstance(df, gpd.GeoDataFrame)
        self.assertIn('geometry', df)