parsing

Python: Iterate and modify a complex dict including lists

Python: Iterate and modify a complex dict including lists Question: I need to iterate through a complex dictionary and modify it according to several conditions. This is a very basic example of the dict a = { ‘x’ : ["x1", "x2", ‘x3’], ‘y’ : [ {‘y1’ : 1}, {‘y2’ : 2.0}, {‘y3’ : True}, {‘y4’ …

Total answers: 2

How to make python textx parse Island Grammars

How to make python textx parse Island Grammars Question: I am trying to parse a network device configuration file, and though I would be going through the whole file, I will not want to include all the terms of the file, but only a subset. So assume that the configuration file is as follows: bootfile …

Total answers: 1

How to iteratively retrieve the right information from beautiful soup elements?

How to iteratively retrieve the right information from beautiful soup elements? Question: I try to retrieve information from EZB press releases. To do so I use BeautifulSoup. Since the structure (HTML) of the press releases is changing over time, it is difficult to retrieve the date of the press releases with a single selector. Hence …

Total answers: 2

Selenium find_element broke for loop

Selenium find_element broke for loop Question: I find elements with find_elements and after getting child elements with find_element, but the iteration doesn’t work further after find_element and the loop stops (although there are several elements found with find_elements) import os from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.common.by import By from selenium.webdriver.support.wait import …

Total answers: 1

How to make changes in XML file in Python

How to make changes in XML file in Python Question: I have a xml file MC.xml contents of which are <?xml version="1.0" encoding="UTF-8"?> <MCOO type="list"> <AAA> <Active value="True" li="True" mv="True"/> <Plot value="True" li="False" mv="False"/> <Color value="#990000"/> </AAA> <BBB> <Active value="True" li="True" mvl="True"/> <Plot value="True" li="False" mvl="False"/> <Color value="#990000"/> </BBB> <CCC> <Active value="True" li="False" mv="True"/> <Plot …

Total answers: 1

Using configparser to remove section name only but retain its key and value pairs

Using configparser to remove section name only but retain its key and value pairs Question: I am trying to remove the section from ini file but i want to retain that section’s keys and values. I tried to remove a section like this with open(‘testing.ini’, "r") as configfile: parser.read_file(configfile) print(parser.sections()) parser.remove_section(‘top’) print(parser.sections()) with open(‘testing.ini’, "w") …

Total answers: 1

why exception is rised on some java files using JavaLang python package

why exception is rised on some java files using JavaLang python package Question: I am aiming to obtain all methods names in a java file and count theit lines of code. I actually managed to obtain something using the javalang parser for python. It identifies all methods but not creator which make me think there …

Total answers: 1

Replace one column is txt file

Replace one column is txt file Question: I have several .txt files of annotation frame coordinates of objects in images. The .txt file looks like below, the number of rows are not fixed and different for each .txt file. 2 0.063542 0.192593 0.021528 0.185185 2 0.106944 0.298148 0.030556 0.300000 2 0.186806 0.600000 0.061111 0.577778 Now …

Total answers: 3

Comparing data from 2 text files in python

Comparing data from 2 text files in python Question: There are 2 text files, the first contains words (file1.txt) that will need to be searched in the lines of another file, for example: window factory scientist In another text file, data (file2.txt) where to look for, for example: window – Anton, game crossroads, snow factory …

Total answers: 1