Home > Blockchain >  How to add a URL into a dataFrame
How to add a URL into a dataFrame

Time:10-25

I'm trying to add a specific URL into a dataFrame in order to export the information into a csv. Every row of this csv has a specific ID added at the end of the URL attached

The URL example would be like this:

https://example.navigator.com/index.php?pagina=demoData;ID

The problem is that if I convert this into a string and then put into a dataframe column once I export the csv looks like this.

enter image description here

Few Lines of the CSV:

enter image description here

It separates in 2 columns the URL.

How can I add the ID properly in order to have the entire URL in one column in the resulting csv?

Thank you

CodePudding user response:

import pandas as pd
s = 'https://example.navigator.com/index.php?pagina=demoData;ID'
pd.DataFrame([s,s]).to_csv('test.csv', sep=';')

creates

;0
0;"https://example.navigator.com/index.php?pagina=demoData;ID"
1;"https://example.navigator.com/index.php?pagina=demoData;ID"

If you open it with Excel, you can use the From text/csv function in the Tab Data and specify the delimiter if you encounter further problems.

  • Related