On 15/07/2019 21:28, Mats Wichmann wrote: >> a float of s. Of course I can't edit a 4G file in any editor that I >> have installed, so I have to work with the fact that there is a bit of >> text in there that isn't quoted.
Try sed, it's on most Unix like OS. It doesn't read the entire file into memory so file size is not usually an issue. I've never tried 4G but I have gone over 1GB before with no issues. If you have never used sed before its batch oriented so you need to practice your commands in advance on something like vim or ex then translate them to a file. But it sounds like it would be a worthwhile automation step in your workflow. Write once, use often... > course Python can do that too, by working line-at-a-time, explicitly by > calling readlines() or implicitly by looping over the file handle. The > latter looks something like this; > > with open("/path/to/datafile", "r") as f: > for line in f: > if REDFLAGTEXT in line: # skip these > continue > do-something-with line All true, but sed - once you get used to it! - is easier IMHO and usually faster than Python - it's written in C... -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor