Skip to main content

Timeline for A function that opens a CSV file

Current License: CC BY-SA 4.0

10 events
when toggle format what by license comment
Sep 17 at 21:09 comment added P. Hopkinson Unfortunately it looks like the readline module is not available in the windows version of python. Apparently it has a license clash with the MKL libraries (which underpin the most common numpy installation, amongst other things) so it isn't available, despite being part of the standard library!
Sep 17 at 21:04 comment added P. Hopkinson Interesting, thank you! I only use a CLI to execute code (and launch DOS games, back in the day) and had no idea that you had that they offer this kind of functionality.
Sep 17 at 11:33 comment added STerliakov (and usually you won't need even that, if possible - better take file paths as sys.argv, users will be familiar with how their own shell behaves and won't have to adapt to your implementation at all)
Sep 17 at 11:29 comment added STerliakov @P.Hopkinson My "recommendation" is in the standard library. Takes ~3 lines to set up (or ~30 to write your custom completer that, for example, excludes "hidden" files unless asked with an explicit period): import readline; readline.parse_and_bind('tab: complete'); readline.set_completer_delimiters(' \n\t'). That's not a file picker, but anyone familiar with CLIs will immediately know how to tab-complete paths:) Nowadays should work on all platforms - there are Mac and Windows surrogates that try to resemble GNU readline, and python wraps the available one.
Sep 16 at 23:19 comment added P. Hopkinson @STerliakov do you have a recommendation? Forcing users to enter their own filepaths is a poor choice in the cases where a GUI is available (most cases). Writing a custom CLI file picker doesn't seem proportionate to the problem. Is there a widely used and ideally low-dependency library that solves the problem with a CLI?
Sep 16 at 17:04 comment added STerliakov Please don't suggest tkinter.filedialog (GUI) for a CLI app... There are TUI file pickers, but please do not assume that a program running in CLI will have access to any desktop environment and ability to open GUI elements, and even if it has - that the end user wants a UI. Just imagine find or grep slapping you in the face with a GUI dialog every time you mistype or omit the filename. Oh, wait, sounds like MS Windows...
Sep 16 at 4:18 comment added JackInDaBeanSock Thanks for replying! I plan to add a dialog navigation to the file once the rest of the program is built out - I wasn't sure how to do that yet so was waiting until I learnt, I'll look into tkinter.filedialog! I see how having no graceful way to quit is unclean, I wasn't sure of how to rectify this though. I put the print_menu_prompt() in a different file for the sake of readability - I can always add it back, even as function as the bottom of the file! I appreciate the criticism, best way to learn! Thanks for the help.
Sep 15 at 21:54 history edited P. Hopkinson CC BY-SA 4.0
added 106 characters in body
S Sep 15 at 21:47 review First answers
Sep 15 at 22:26
S Sep 15 at 21:47 history answered P. Hopkinson CC BY-SA 4.0