[Solved] Python and shell script [closed]

[ad_1] Working with Excel files is definitely something people care about. I love the following author who wrote a book on how to use Python in everyday life: https://automatetheboringstuff.com/chapter12/ This chapter in particular deals with Python and Excel. He describes how to use the package openpyxl. You should be able to read and edit the … Read more

[Solved] Remove duplicates and combine multiple lists into one?

[ad_1] Create a empty array push the index 0 from childs arrays and join to convert all values to a string separate by space . var your_input_data = [ [“hello”,”hi”, “jel”], [“good”], [“good2″,”lo”], [“good3″,”lt”,”ahhahah”], [“rep”, “nice”,”gr8″, “job”] ]; var myprint = [] for(var i in your_input_data){ myprint.push(your_input_data[i][0]); } console.log(myprint.join(‘ ‘)) 2 [ad_2] solved Remove duplicates … Read more

[Solved] File not found Error in reading text in python [duplicate]

[ad_1] Replace fileref = open(“H:\CloudandBigData\finalproj\BeautifulSoup\twitter.txt”,”r”) with fileref = open(r”H:\CloudandBigData\finalproj\BeautifulSoup\twitter.txt”,”r”) Here, I have created a raw string (r””). This will cause things like “\t” to not be interpreted as a tab character. Another way to do it without a raw string is fileref = open(“H:\\CloudandBigData\\finalproj\\BeautifulSoup\\twitter.txt”,”r”) This escapes the backslashes (i.e. “\\” => \). An even better … Read more

[Solved] Error from division operator

[ad_1] The code you had was: Traceback (most recent call last): File “C:/Users/Leb/Desktop/Python/test.py”, line 14, in <module> dayspermonth = (hourspermonth) / (hourspernight) * 24 TypeError: unsupported operand type(s) for /: ‘NoneType’ and ‘int’ That’s because on line 12 you put hourspermonth = print(“you also sleep”, hourspermonth,”hours per month”). Take out hourspermonth from your script. Same … Read more

[Solved] How to amend (e.g. add/remove) the values of a ttk.Treeview tag (tkinter)?

[ad_1] According to the tcl documentation, a ttk.Treeview widget does have commands to add and remove a tag from a node or a list of nodes. However, these methods are not provided in the official tkinter wrapper; see the Treeview class in /usr/lib/python3.8/tkinter/ttk.py. Building on the comment by @JasonYang and answer by @CoolCloud, the test … Read more

[Solved] in python how to count how many times certain words appear without specifying the word [duplicate]

[ad_1] I have a solution using Counter for you: import collections data = “”” ——————————— Color: red/test/base person: latest ——————————— Color: red-img-tests person: latest ——————————— Color: red-zero-tests person: latest ——————————— Color: red-replication-tests person: latest ——————————— Color: blue person: latest ——————————— Color: black/red-config-img person: 7e778bb person: 82307b2 person: 8731770 person: 7777aae person: 081178e person: c01ba8a person: … Read more

[Solved] Distance between two alphabets in a string

[ad_1] You can just use the str.index(char, [beg, end]) method to retrieve the position of a character inside a string. The method allows you to add a beginning and end position that you can use to check for the different occurrences. Here the code: s=”CNCCN” dist = s.index(‘N’, s.index(‘N’) + 1) – s.index(‘N’) And its … Read more

[Solved] Open txt file in python

[ad_1] Notice that the names are separated by a colon(:) so add : in split() to split them and store them in multiple variables: with open(“filename.txt”) as f: for line in f : word1,word2,word3 = line.split(“:”) print(word1) print(word2) print(word3) 0 [ad_2] solved Open txt file in python