Categories

## Editing a file based on a pattern appearance

I have a file that contains text and numbers like this: state(1, s(1,a), [s(1,b)]). state(1, s(1,b), [s(1,a)]). state(1, s(2,a), [s(2,b)]). state(1, s(2,b), [s(2,a)]). state(1, s(3,a), [s(3,b)]). state(1, s(3,b), [s(3,a)]). state(1, s(4,a), [t(1), t(2)]). state(1, s(5,a), [t(1), t(3)]). state(1, s(6,a), [s(6,b)]). state(1, s(6,b), [s(6,a)]). …so on I want the numbering with in s(x,y) to change as […]

Categories

I am using raster() inside an if statement and I get the following error: Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer", : Cannot create a RasterLayer object from this file. (file does not exist) I am cheching all the paths and are correct. Perhaps the function file.path() is not correct to get the […]

Categories

## How to limit number of permutations

I have like 20 short strings that I want to permutate, but I just want the permutations that have len=8. I could do something like that, but it calculates aaalll possible permutations and then print. import itertools p = itertools.permutations([s1, s2, s3, s4, s5, s6,…]) for i in p: s = ”.join(j for j in […]

Categories