I want to shorten and clean up a CSV file to use it in ElasticSearch. but there are line breaks in some Dataframes (cells) and it is not possible to parse the CSV to ElasticSearch. I now shortend the CSV with pandas and tried to remove the newline but it is not working.
Code is the following:
import pandas as pd
f=pd.read_csv("test.csv")
keep_col = ["Plugin ID","CVE","CVSS","Risk","Host","Protocol","Port","Name","Synopsis","Description","Solution",]
new_f = f[keep_col].replace('\\n',' ', regex=True)
new_f.to_csv("newFile.csv", index=False)
the shortage is working, but i have newlines in Description, Synopsis and Solutions. Any idea how to solve it with Python / Pandas? The CSV has about 100k entries so the linebreak removal has to be done in every entry.