Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to write semicolon separated value in one csv column?

I write with python automated names to a CSV file. However, I have the problem that I include names that are separated with a semicolon. Therefore, names that are separated with a semicolon are written in two columns although I want to have them only in one.

product_data= product_data + ";" + re.search(r">(.*?)</", i).group(1)

Within the the re.search() function I filter names which are between "> <". The code works but as described above, I want names to be written in one column and not in two.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

I’m not entirely sure if I fully understand the question, but let me attempt to answer it. CSV files just require some time of character to serve as the delimiter that divides each column in a row. What if instead of using a semi-colon as a delimiter you used a comma or, if that appears somewhere in names or product_data perhaps you could use "|"? Additionally, if you wanted to remove the semicolon from the names, you could turn re.search(r">(.*?)</", i).group(1) into "".join(re.search(r">(.*?)</", i).group(1).split(";")). Hope this helps!

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading