I have a text file in this format: I want to check if the image name is the same and then concatenate those lines into one line with the following format: I have tried something like this but don’t know how to do the actual comparison and also don’t quite know what logic to apply since the first line_elements[0] will
Tag: text
Remove text lines and strip lines with condition in python
I have a text file in this format: I want to remove the lines that don’t have a [number1,number2,number3,number4,1] or [number1,number2,number3,number4,5] ending and also strip the text line and remove the [blocks] -> [number1,number2,number3,number4,number5] that don’t fulfill this condition. The above text file should look like this in the end: My code: I have tried something like this and it
Use list items as column seperators pd.read_fwf
I have text files containing tables which I want to put into a dataframe. Per file the column headers are the same, but the width is different depending on the content (because they contain names of different lengths for example). So far I managed to get the index of the first character of the header, so I know where the
collect subprocess outputs and write to excel in python
I wrote a loop in python to cope with a list of tasks, and during every loop certain outputs (plain text) from either stderr or stdout will be generated, what I want is trying to collect them inside python and at the end write them together into excel. I also tried before write them respectively after every loop into excel
How to change multiple buttons text using only one function, tkinter python
I would like to use only one function (self.toggle) for all of my buttons in my GUI instead of doing each for every button. I have tried to change name of self.button only without numbers and then I had text changing on just one button not the one required. Is there simple way to do just one function? I’m just
Adding a full stop to text when missing
How to add a full stop to a text please? I am not able to get the desired combined text. Answer You can use where and cat: Result: (this also works for the case when text1 is given and text2 is NaN)
Count the number of times a group of words appear in a text
I have 4 lists of words that categorise something and a tokenised text by word. I would like to count the number of occurrences of the words in these lists in a certain text but as a sum of the words for each list. Therefore the results would show an occurrence of 10 animal words, 20 colour words, 6 food
Remove specific string char at the beginning of each lines of a txt file using python
I’m currently working on a script in python. I want to convert an xls file into a txt file but I also want to clean and manage the data. In the xls files, there’s 4 columns which does interest me. Here is a sample of the txt I get from the conversion : To get this result I used this
Extract Number of pages from a text column
I have a text column which contains comments like: 6 pages, LaTeX, no figures 19 pages, latex, 4 figures as uuencoded postscript files Invited Talk at the “VII Marcel Grossman Meeting on General Relativity” – Stanford, July 1994. 14 pages, latex, five figures, which will be available upon request. 15 pp. Phyzzx I am looking to extract the number of
Regex Help for text/pattern between two keywords
I am trying to extract text between two words. The below pattern repeats itself with modifications in between ‘start keyword’ and ‘end keyword’ across the text document. The document has paragraphs and text before and after the following patterns, which i don’t want to extract. Can anyone help me with the regex for the following ? which would extract all