Skip to content
Advertisement

Tag: rename

Replace character in file name with regex python

My script should replace the “|” character of a file it finds via regex in a directory with an “l”. The code runs but filenames are not replaced. What is wrong? Answer Joshua’s answer and the many comments, especially the suggestions from ekhumoro, already pointed out issues and guided to the solution. Fixed and improved Here is my copy-paste ready

Renaming scientific paper PDFs from one name pattern to another name pattern

I am trying to automate the renaming of PDFs of scientific papers from one name pattern to another using python. The name pattern the PDFs occur in looks like this: Cresswell, K., Worth, A., & Sheikh, A. (2011). Implementing and adopting electronic health record systems. Clinical governance- an international journal. i.e. “LastName1, FirstLetterGivenName1., LastName2, FirstLeterGivenName2., […]. (Year). Title. Journal.” The

rename a dataframe automatically

I want to automatically rename my dataframe with 3 name ,I tried with this code but it shows me each time only the last name : the result I want to achieve : Answer Can do it dynamically by multiplying the list to repeat it. Then slice by the length of the df.columns

Rename nested field in spark dataframe

Having a dataframe df in Spark: How to rename field array_field.a to array_field.a_renamed? [Update]: .withColumnRenamed() does not work with nested fields so I tried this hacky and unsafe method: I know that setting a private attribute is not a good practice but I don’t know other way to set the schema for df I think I am on a right

How to rename PDF file, with texts extracted from the PDF file?

I am trying to use Python to rename PDF file using part of the file content. Here is the situation. The PDF file is a commercial invoice, contains wordings “Commercial Invoice” and “Department”. I want to rename the file to “Commercial Invoice” and ” Department “, such as “353624 HR”. Here is what I have so far: it works until

Advertisement