With perl we can run perl -p . That wraps a foreach loop around the code and executes the code on the file. What I'm looking for is something like
StringReplace[filename,"\t"->","]
and then I get a new file in which the string replace happened (the above would convert a .tsv to a .csv). Doesn't have to be StringReplace, can be anything that takes a line of stuff as input. Total[filename] would total all numbers in the rows of the file.
I do NOT want the whole file in kernel memory!
also like sed on Linux (stream editor -- works line by line)
That is like "scripting" the M command line-by-line (during MS-DOS we used to call that "batch mode" -- really means line-by-line).
WriteString["newfile", StringReplace[ReadString["file"], "\t" -> ","]]
. However, I would guess that any dedicated command-line tool would be orders of magnitude faster than MMA at this. $\endgroup$ReadLine
+StringReplace
+WriteLine
? $\endgroup$