I've got the next csv file:
Summary,Issue key,Issue id,Issue Type,Status,Project key,Attachment,Attachment.1,Attachment.2,Attachment.3,Attachment.4,Attachment.5
Find issue,IS-11,576,Task,Solved,One-1,10/28/21 11:49;Olga_Sokolova;SALUPRJBKK-1663_2021-10-28 14-38-01-372.mp4;file://SALUPRJBKK/SALUPRJBKK-1663/SALUPRJBKK-1663_2021-10-28 14-38-01-372.mp4
I need to choose all the attachments values and replace the "space" in the filename to " ". The main problem is to skip the first 'space' after the date in the attachment value and also to get all the attachment value. I tried to use standart csv reader, pandas and etc. but I can only get name of the column
import pandas as pd
data = pd.read_csv("SALUPRJBKK_new_10.csv")
for i in data:
if "Attachment" in i:
print(i)
CodePudding user response:
Select 'Attachment' columns using filter
and replace
all whitespaces by ' ' then update
your dataframe in place:
df.update(df.filter(like='Attachment').replace(' ', ' ', regex=True))
My advise if you need to escape HTML entities is to use quote
from urllib
module:
from urllib.parse import quote
df.update(df.filter(like='Attachment').fillna('').applymap(quote))
CodePudding user response:
consider specifying the separotor:
data = pd.read_csv("SALUPRJBKK_new_10.csv", sep=",")
Note: there is a mix of seperator in your example "," or ";"
and if you want to acces only to "Attachment" do:
data["Attachment"]
CodePudding user response:
I think do you need a url encode.
Try with this:
import urllib.parse
query = 'Hellóóó W r l d @ Pyt@@ h on.mp4'
newUrl = urllib.parse.quote(query)
print(newUrl)
And now the encode result:
Hellóóó W r l d @ Pyt@@ h on.mp4
The text or url is encoded and change all the special characters in string.