Linked Questions
33 questions linked to/from Remove all special characters, punctuation and spaces from string
1 vote
2 answers
2k views
How to remove special characters from strings in python?
I have millions of strings scraped from web like: s = 'WHAT\xe2\x80\x99S UP DOC?' type(s) == str # returns True Special characters like in the string above are inevitable when scraping from the web. ...
1 vote
1 answer
3k views
Reading an XML file which contains unicode in python 2.7
I'm trying to python 2.7.6 with ElementTree to parse an xml file which is encoded in unicode from some server, and save the contained data locally. import xml.etree.ElementTree as ET def normalize(...
2 votes
2 answers
1k views
Create new dataFrame based on reformatted columns from old dataFrame
I imported the data from a database df = spark.read.format("com.mongodb.spark.sql.DefaultSource").option("uri", "mongodb://127.0.0.1/test.db").load() I have selected the double columns using ...
0 votes
2 answers
866 views
Strip punctuation with regular expression - python
I would like to strip all of the the punctuations (except the dot) from the beginning and end of a string, but not in the middle of it. For instance for an original string: @#%%.Hol$a.A.$% I would ...
1 vote
3 answers
1k views
Remove special characters except space in an list without using re - Python [duplicate]
I have the list lst= ["is ", "star,", "the-"] and I want to remove ',', '-' without using re. I used the below and it works but I wondered if there is something simpler: ...
0 votes
1 answer
1k views
python replace special character
I want to copy the file to a new place in windows7 64bit. But I found some special characters in the file name can cause error 22 when using shutil.copy2 (but this file is legal in windows GUI and can ...
0 votes
2 answers
745 views
How to remove all Special Character before to push the data to MSSQL
I have an excel file that I want to push a sheet to database SQL, But before to push the data I want to replace or remove all Special chacater like brackets (), % and Spaces.. So for example I have a ...
3 votes
1 answer
643 views
Is there a correct way to use parameters in a SQL injection safe way with the InfluxDB python client, much like the mogrify function in psycopg?
Is there a correct way to use parameters in a SQL injection safe way with the InfluxDB python client, much like the mogrify function in psycopg? https://github.com/influxdata/influxdb-python/ http://...
1 vote
2 answers
821 views
How to extract specific strings from string, for each row in a dataframe; and count for each item
So I have a df that looks like this: Text ___________________________ Hello, Jim. I knew it was Sam! Sam why?! I have a known list of names I want to extract from each row if they appear, and ...
0 votes
1 answer
816 views
How to match a string to another string ignoring the special character and space?
I am trying to match a value of a json file in my python code to another value of another API call within the same code itself. The values basically the same but it does not match because sometimes ...
0 votes
2 answers
527 views
Removing random special characters from complete dataframe
Post interim dataframe transformations, if we need to place a safety mechanism to remove special random characters from complete pandas dataframe. What would be the best way ? Example DF : data = {'...
2 votes
1 answer
161 views
Scraping in Python with BeautifulSoup
I've read quite a few posts here about this, but I'm very new to Python in general so I was hoping for some more info. Essentially, I'm trying to write something that will pull word definitions from ...
-3 votes
1 answer
149 views
What is the fastest and simplest way to remove "\" from a string [closed]
when im parsing a lot of data with python and it can happen that some parts of the data contains strings/chars with \, this can lead to problems when working with the data so my goal is minimize ...
-1 votes
1 answer
170 views
Discord mp3 downloader security concerns
So i'm writing a python discord bot that uses yt-dlp to download a song then send it to a discord channel. Problem is, I need to save the mp3 to a path to reupload it, but i think my code would be ...
0 votes
3 answers
74 views
How to print different words in each line from the text document using python?
I am new to python and I would like to print different words from the sentence. Below is the text file Test.txt 1. As more than one social media historian has reminded few people, the Stonewall ...