Created
April 4, 2023 14:57
-
-
Save kourbou/3e806615f364ca108f8eb329aac3d5a6 to your computer and use it in GitHub Desktop.
Small utility to display the contents of a `.parquet` file in `notepad.exe`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ctypes | |
| import os | |
| import subprocess | |
| import sys | |
| import tempfile | |
| import traceback | |
| import pandas as pd | |
| MessageBoxW = ctypes.windll.User32.MessageBoxW | |
| # https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messageboxa | |
| MessageBoxW.argtypes = ( | |
| # [in, optional] HWND hWnd, | |
| ctypes.c_void_p, | |
| # [in, optional] LPCSTR lpText, | |
| ctypes.c_wchar_p, | |
| # [in, optional] LPCSTR lpCaption, | |
| ctypes.c_wchar_p, | |
| # [in] UINT uType | |
| ctypes.c_uint, | |
| ) | |
| # The message box contains one push button: OK. This is the default. | |
| MB_OK = 0x00000000 | |
| # A stop-sign icon appears in the message box. | |
| MB_ICONERROR = 0x00000010 | |
| if __name__ == "__main__": | |
| try: | |
| dataframe = pd.read_parquet(sys.argv[1]) | |
| with tempfile.NamedTemporaryFile("w", suffix=".txt", delete=False) as info: | |
| info.write(sys.argv[1]) | |
| info.write("\n\n") | |
| dataframe.info(buf=info) | |
| try: | |
| subprocess.call(["notepad.exe", info.name]) | |
| finally: | |
| os.unlink(info.name) | |
| except Exception as e: | |
| MessageBoxW(None, traceback.format_exc(), repr(e), MB_OK | MB_ICONERROR) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment