How to join strings into one sentence separated by spaces

I have this code: with open("wordslist.txt") as f: words_list = {word.removesuffix("\n") for word in f} with open("neg.csv") as g: for tweete in g: for word in tweete.split(): if word not in words_list: print(word) and the output is like this: gfg best gfg I am I two two three ………….. I want to remove the newline… Read More How to join strings into one sentence separated by spaces

Writing string to a file on a new line every time in Python

I have a loop, which have to write text on a new line every time. Here`s the code in Python: for j in b: data = json.loads(json.dumps(j)) data = json.dumps(data) data = json.loads(data) from_id = data[‘from_id’] text = data[‘text’] if (os.path.exists(f'{user_id}.txt’)): with open(f'{user_id}.txt’, ‘w’, encoding=’utf-8′) as file: file.write(f'{from_id}: {text}\n’) I tried to use \n at… Read More Writing string to a file on a new line every time in Python

Retrive only replacement template of regex in C#

can i get only the substitution of the Regex.Replace? Example. String text = @"asdfgs sda gsa ga s SECTOR:124 NAME:Ricko asdfgs sda gsa ga s"; String regex = "^SECTOR:(\d+) NAME:(\w+)"; String substitution = "$2 $1"; String result = Regex.Replace(text, regex, substitution); Console.WriteLine(result); Normal result asdfgs sda gsa ga s Ricko 124 Wanted result Ricko 124… Read More Retrive only replacement template of regex in C#

How to don't allow set only the same characters and only special sign – regex js

I’m looking for some regex pattern to: not allow set the same characters not allow only special signs. So: 11111111 – not allow 1111811111 – allow rrrrrrrr – not allow rrrrrrrrrr5 – allow 11111111% – allow %$!@$!@@@@ – not allow %%%%%%%%%1 – allow I found regex which is helpful for recognize that string has only… Read More How to don't allow set only the same characters and only special sign – regex js

Remove items from one list if they contain strings from another list

I’m looking for the most efficient way to remove items from one list if they contain strings from another list. For example: B list contains: TomWentFishing SueStayedHome JohnGoesToSchool JimPlaysTennis A list contains: GoesToSchool SueStayed C list should contain: TomWentFishing JimPlaysTennis I’ve used this code, but it takes up a lot of time as the lists… Read More Remove items from one list if they contain strings from another list

How to search json for a string and output a parent value using jq?

Trying to pull a value out with jq, but didn’t seem as easy as i originally thought. I have a variable of CAR="baga6e~tlwdcmli__QmbHKa~G65fMXzh.car". How can i use this variable to return the parent "piece_cid" ? Example: Using a bash varible of $CAR with a value of baga6e~tlwdcmli__QmbHKa~G65fMXzh.car, id be able to get the results saved… Read More How to search json for a string and output a parent value using jq?