Monday 25 March 2024

SEARCH ME

Dick Pountain /Idealog 347/ 06 Jun 2023 11:22 “I'm writing this column sitting under a magnificent copper beech tree in the West Meadow at the Kenwood Estate in North London, with tall summer grass all around and even a foxglove in the corner of my vision. You might not find this any big deal - after all mobile computers have been around for a long time - but it has taken me personally twenty years to achieve this feat, and I've only achieved it now thanks to my Palm Pilot and a neat little add-on keyboard called the GoType, whose purchase was the best £70 I've spent in a long time.” In actual fact I’m writing this column sitting under a magnificent copper beech tree in The Regent’s Park 24 years later, on a Moto g8 PowerLite phone, and I’ve just pasted that quote from Idealog 59 (1999) in seconds merely by searching for ‘copper beech’. That was possible because I post my old columns, six months in arrears, onto Google’s Blogger, which has an excellent full-text search facility. Of course this search only works on plain text files, not binary or encrypted ones, so even though over the years I’ve written columns in TextPad, MS Word, Libre Writer and now Google Docs, I upload them by cut-and-paste as plain text. The searchability of archives bothers me a lot, because I gave up on huge document management systems and NASes long ago in favour of simplicity, and that’s not an easy row to hoe. Recently an old friend, who’s just retired as a professor of robotics, mailed me to ask for a Byte article I wrote about his company back in 1985 and I was keen to oblige. I found the right Byte issue on the Internet Archive using their own search engine, which gave us a PDF of the page, and I located the original copy file on my local machine too. But this experience set me to thinking that I really don’t have an effective full-text search on my Chromebook that can locate topics in the many decades of files I keep locally (I love The Cloud, but I don’t trust it). I was about to write that this wasn’t a problem when I was a Windows user, thanks to its indexing system, until I recalled the appalling problems I used to have with that system consuming vast amounts of CPU time, and occasionally going metastatic and filling my whole hard drive with its index file. Anyway, I checked out grep-like apps in the Android Playstore only to discover they were all indescribably useless – several didn’t work at all, all were full of dodgy ads, and almost all failed to access external USB drives. I got so fed up installing and uninstalling these monstrosities that I formed a crazy idea that I needed to write my own. I entertained that idea for several minutes, before remembering that I’m working with Android running on Linux within a ChromeOS cocoon, and that I’ve always hated I/O programming at the best of times. So I had an even crazier idea, that I would ask my new friend ChatGPT to write one for me. I’ll admit that I considered this more as an experiment (and possible column topic!) than a serious strategy. So off I went: Me: “write python 3 program to find address of external SD card on Asus C301S Chromebook” ChatGPT: “On Chromebooks, external storage devices like SD cards are mounted under the /media directory. You can use the os module in Python to list the contents of the /media directory and find the address of the external SD card. Here's a Python 3 program that accomplishes this: … “ That Python code didn’t work quite immediately because it turns out the SD card mount directory name isn’t ‘/media’ on my machine but actually ‘/storage’. With that one alteration it just worked. I asked for a second Python 3 program to search for a target string within multiple text files, spliced them together with a couple of extra lines to format the output the way I wanted and it was done, in a couple of hours. My new app worked perfectly except for a rather amusing bug: some of the Byte columns would crash it with a Unicode error, which I discovered was because back in those prehistoric days my text editor used to insert a character code for the ‘£’ sign that conflicts with 64-bit Unicode. Python’s ‘try…except’ error handling soon put a stop to that. I was deeply impressed (and a little scared) by how fast ChatGPT generated such excellent code, but I don’t think I’ll be pushing my luck by asking it for an app that can search within DOCX and PDF files too. [Searching Dick Pountain’s 341 columns at https://dickpountain-idealog.blogspot.com/ will reveal only one occurrence of ‘copper beech’]

No comments:

Post a Comment

SOCIAL UNEASE

Dick Pountain /Idealog 350/ 07 Sep 2023 10:58 Ten years ago this column might have listed a handful of online apps that assist my everyday...