gpt4 book ai didi

python - 从文本文件中提取数据

转载 作者:太空宇宙 更新时间:2023-11-04 01:17:02 26 4
gpt4 key购买 nike

<分区>

我需要从文本中提取(具体:LotLongnametype)数据文件 (.txt) 并从提取的数据中创建一个凸包。据我所知,提取的数据应该是浮点格式,而不是字符串。

文本文件有点像这样(有更多数据):

location_type, parent_station, stop_id, stop_code, stop_name, stop_desc, stop_lat, stop_lon, zone_id
0,,10000,10000,"Albany Hwy After Armadale Rd","",-32.14796,116.020217222222,4
0,,10001,10001,"Albany Hwy After Frys L","",-32.144985,116.018336666667,3
0,,10002,10002,"Albany Hwy After Clarence Rd","",-32.1420722222222,116.017182777778,3
0,,10003,10003,"Albany Hwy After Rogers L","",-32.1391138888889,116.017382222222,3
0,,10004,10004,"Albany Hwy After Galliers Av","",-32.1365533333333,116.017569444444,3
0,,10005,10005,"Albany Hwy Armadale Kelmscott Hospital","Armadale Kelmscott Hospital",-32.1348155555556,116.017707222222,3
0,,10006,10006,"Albany Hwy After Lilian Av","",-32.1304322222222,116.018038333333,3

但直到现在我(从早上开始就一直在尝试和错误)只能提取整个数据,而不是特定的数据。

 try:
fp = open(filename)
myList = []
next(fp)
for f in fp:
myList.append(list(f.strip().split(",")))

fp.close()

return myList

需要帮助来解决这个问题。非常感谢。

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com