Batch / Find And Edit Lines in TXT file

On a native Windows install, you can either use batch(cmd.exe) or vbscript without the need to get external tools. Here’s an example in vbscript: Set objFS = CreateObject(“Scripting.FileSystemObject”) strFile = “c:\test\file.txt” Set objFile = objFS.OpenTextFile(strFile) Do Until objFile.AtEndOfStream strLine = objFile.ReadLine If InStr(strLine,”ex3″)> 0 Then strLine = Replace(strLine,”ex3″,”ex5″) End If WScript.Echo strLine Loop Save as … Read more

Splitting large text file into smaller text files by line numbers using Python

lines_per_file = 300 smallfile = None with open(‘really_big_file.txt’) as bigfile: for lineno, line in enumerate(bigfile): if lineno % lines_per_file == 0: if smallfile: smallfile.close() small_filename=”small_file_{}.txt”.format(lineno + lines_per_file) smallfile = open(small_filename, “w”) smallfile.write(line) if smallfile: smallfile.close()

Plot multiple lines (data series) each with unique color in R

If your data is in wide format matplot is made for this and often forgotten about: dat <- matrix(runif(40,1,20),ncol=4) # make data matplot(dat, type = c(“b”),pch=1,col = 1:4) #plot legend(“topleft”, legend = 1:4, col=1:4, pch=1) # optional legend There is also the added bonus for those unfamiliar with things like ggplot that most of the … Read more