-4
votes
1answer
61 views

Python replace string in file

i need something to replace a string in a file wich is placed in that mktemp folder. this file is named autounattend.cfg and contains a string named %PASSWORD this string need to be replaced with ...
0
votes
2answers
83 views

In Python 2.7, how can i replace 't' with 'top' and 'h' with 'hop' only when 'th' is not visible

I am new here and python as well but i want to give it a try! I would like to replace 't' with 'top' and 'h' with 'hop' in a sentence , only when 'th' is not visible because 'th' will become 'thop'. ...
0
votes
0answers
40 views

Python alter lines for all files in folder, replacing existing files

I am trying to write a python script which goes through all files in a folder, and alters those lines containing a certain a href. I'm trying to get the script to add a .html extension to the href, ...
6
votes
3answers
81 views

Simultaneous .replace functionality

I have already converted user input of DNA code (A,T,G,C) into RNA code(A,U,G,C). This was fairly easy RNA_Code=DNA_Code.replace('T','U') Now the next thing I need to do is convert the RNA_Code ...
0
votes
2answers
35 views

Change all the occurrences of a particular value in a CSV file in Python

I have a CSV file that needs to be cleaned up. I wrote code with separate functions for each column to replace some value, say 'a' in column 1 with 'aaa', and ' ' (blank) in column 2 with '0'. Can we ...
0
votes
0answers
28 views

combining multiple CSV processes with python

I work for a local municipality and provide mapping for the police department. Each month, I get a report from them that I use to plot their calls. For a while, I manually edited the CSV file to ...
0
votes
3answers
51 views

replace blank values in column in csv with python

I am trying to replace blank values in a certain column (column 6 'Author' for example) with "DMD" in CSV using Python. I am fairly new to the program, so a lot of the lingo throws me. I have read ...
0
votes
1answer
27 views

Replace Special Characters in Field Names in Python

I am trying to replace the special characters in the field name (or first row) in my CSV file using python. There are a lot of questions closely related to special characters but I can't seem to find ...
5
votes
3answers
53 views

Python: replace terms in a string except for the last

How does one go about replacing terms in a string - except for the last, which needs to be replaced to something different? An example: letters = 'a;b;c;d' needs to be changed to letters ...
0
votes
2answers
53 views

file.replace('abcd') also replaces 'abcde' How do I only replace exact value?

def censor2(filename): infile = open(filename,'r') contents = infile.read() contentlist = contents.split() print (contents) print (contentlist) for letter in contentlist: ...
0
votes
3answers
98 views

Python complex regex replace

I'm trying to do a simple VB6 to c translator to help me port an open source game to the c language. I want to be able to get "NpcList[NpcIndex]" from "With Npclist[NpcIndex]" using ragex and to ...
2
votes
1answer
45 views

Conditional replacement in pandas

I have a dataframe spanning several years and at some point they changed the codes for ethnicity. So I need to recode the values conditional on the year - which is another column in the same ...
0
votes
3answers
86 views

Regular expression replace except first and last characters

What is a regular expression to replace doublequotes (") in a string with escape backslash followed by doublequotes (\") except at the first and last characters of the string. Example 1: Double ...
3
votes
5answers
97 views

Best way to replace \x00 in python lists?

I have a list of values from a parsed PE file that include /x00 null bytes at the end of each section. I want to be able to remove the /x00 bytes from the string without removing all "x"s from the ...
1
vote
2answers
53 views

Using an for/in test with a listed list

I've been trying to check if a user submitted string contains a certain substring, and replacing them when printing a reply. list_in_list = [["I", "you"], ["We", "Us"], ["Her", "Him"]] And I've ...

1 2 3 4 5 24
15 30 50 per page