Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for xpt file #240

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandasgui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def __getitem__(self, key):

def import_dialog(self):
dialog = QtWidgets.QFileDialog()
paths, _ = dialog.getOpenFileNames(filter="*.csv *.xlsx *.parquet *.json")
paths, _ = dialog.getOpenFileNames(filter="*.csv *.xlsx *.parquet *.json *.xpt")
for path in paths:
self.store.import_file(path)

Expand Down
6 changes: 4 additions & 2 deletions pandasgui/run_with_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ def main():
if file_paths:
file_dataframes = {}
for path in file_paths:
if os.path.isfile(path) and (path.endswith('.csv') or path.endswith('.pkl')):
if os.path.isfile(path) and (path.endswith('.csv') or path.endswith('.pkl') or path.endswith('.xpt')):
if path.endswith('.csv') :
df = pd.read_csv(path)
if path.endswith('.pkl'):
df = pd.read_pickle(path)
if path.endswith('.xpt') :
df = pd.read_sas(path, encoding='utf-8')
filename = os.path.split(path)[1]
file_dataframes[filename] = df
show(**file_dataframes)
Expand All @@ -25,4 +27,4 @@ def main():
input()

if __name__ == '__main__':
main()
main()
6 changes: 5 additions & 1 deletion pandasgui/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,10 @@ def import_file(self, path):
filename = os.path.split(path)[1].split('.csv')[0]
df = pd.read_csv(path, engine='python')
self.add_dataframe(df, filename)
elif path.endswith(".xpt"):
filename = os.path.split(path)[1].split('.xpt')[0]
df = pd.read_sas(path, encoding='utf-8')
self.add_dataframe(df, filename)
elif path.endswith(".xlsx"):
filename = os.path.split(path)[1].split('.csv')[0]
df_dict = pd.read_excel(path, sheet_name=None)
Expand All @@ -856,7 +860,7 @@ def import_file(self, path):
df = pd.read_pickle(path)
self.add_dataframe(df, filename)
else:
logger.warning("Can only import csv / xlsx / parquet. Invalid file: " + path)
logger.warning("Can only import csv / xlsx / parquet/ xpt. Invalid file: " + path)

def get_dataframes(self, names: Union[None, str, list, int] = None):
if type(names) == str:
Expand Down