简体   繁体   English

如何从PC中的选定路径读取和打开gal文件?

[英]How to read and open gal file from a selected path in my pc?

I used python code to analyse my data. 我使用python代码分析了我的数据。 But when I wanted to read the gal file I got error. 但是,当我想读取gal文件时,出现了错误。

w = pd.read_gal("C:\\Users\\Yousif\\Downloads\\PythonSpatial\\statess7.gal")

AttributeError Traceback (most recent call last) in () 1 ----> 2 w = pd.read("C:\\Users\\Yousif\\Downloads\\PythonSpatial\\statess7.gal") 3 ()1中的AttributeError Traceback(最近一次调用最后一次)2-> 2 w = pd.read(“ C:\\ Users \\ Yousif \\ Downloads \\ PythonSpatial \\ statess7.gal”)3

AttributeError: module 'pandas' has no attribute 'read' AttributeError:模块“ pandas”没有属性“ read”

Also once I used this function 同样,一旦我使用此功能

w = pysal.open(pysal.examples.get_path("statess7.gal")).read()

I got this error 我得到这个错误

KeyError Traceback (most recent call last) in () 1 ----> 2 w = pysal.open(pysal.examples.get_path("statess7.gal")).read() ()中的KeyError追溯(最近一次通话最近)1-> 2 w = pysal.open(pysal.examples.get_path(“ statess7.gal”))。read()

~\\Anaconda3\\lib\\site-packages\\pysal\\examples__init__.py in get_path(example_name) 33 return os.path.join(base, 'examples', example_name) 34 else: ---> 35 raise KeyError(example_name + ' not found in PySAL built-in examples.') 36 37 〜\\ Anaconda3 \\ lib \\ site-packages \\ pysal \\ examples__init __。py in get_path(example_name)33 return os.path.join(base,'examples',example_name)34 else:---> 35引发KeyError(example_name +'在PySAL内置示例中找不到。')36 37

KeyError: 'statess7.gal not found in PySAL built-in examples.' KeyError:“在PySAL内置示例中找不到statess7.gal。”

I hope to find out how I can read and open gal file from path in my laptop. 我希望了解如何从笔记本电脑中的路径读取和打开gal文件。

.gal are tab delimited, so could just try: .gal是制表符分隔的,因此可以尝试:

w = pd.read_table("C:\Users\Yousif\Downloads\PythonSpatial\statess7.gal")

(does pandas have a .read_gal method? I couldn't find it in the offical docs) (熊猫有.read_gal方法吗?我在官方文档中找不到它)

Edit: The above worked for me, but i had to set the encoding to get a readable dataframe, 编辑:以上为我工作,但我必须设置编码以获取可读的数据框,

df = pd.read_table("C:\path\file.gal", encoding="iso-8859-1")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM