Skip to content
Advertisement

Tag: file

Using a variable as a Filename Python

I cannot get using a variable in the filename to work without throwing an error. I have tried formatting the string as shown above as well as concatenating the variables. Is there anything I can do to solve this? Answer One issue was the closing parentheses, also the date format contain / (slash ex:07/07/21) which will make the filename with

Edit XML file with python

I have an XML file autogenerated with Informatica BDM, it´s very complex for me to edit values I made several attempts with xml.etree.ElementTree but I do not get results. This is an extract from the file: My idea would be to be able to change the parameters, for example: <parameter name=”P_s_spark_executor_memory”>8G</parameter> to <parameter name=”P_s_spark_executor_memory”>16G</parameter> I can only access the values,

Reading next line of big text file

I’m new to python. I have a huge text file (about 15gb), so it is not possible to read in all the lines, I have read here how to fix that problem. Now about my problem. Is it possible to read the next line within a for loop without jumping to the beginning of the loop. This is what I

How to delete a line from a file?

I have two files (file1 and file2) and want to compare each line of file2 with all lines in file1. And if this condition is satisfied: (ln2[1][0] != ln1[1][0]) and (ln2[1][0] != ‘-‘) then I want to remove the current line of file2, i.e. ln2, from the file2. I wrote this code in python, but I have an error. Also,

How can I go to the next line in .txt file?

How can I read only first symbol in each line with out reading all line, using python? For example, if I have file like: In each iteration I must store only one (the first) letter of line. Result of program should be [“a”,”p”,”w”], I tried to use file.seek(), but how can I move it to the new line? Answer file-like

Advertisement