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

Passing out to_csv with specific delimiter, losing the header in the process

Hello everyone as i was passing my df to csv, which has a header.Here a pic for proof.
enter image description here

Interesting enough as i was passing this csv, with a specific delimiter. Because it has a json response and it basically bugs out with comas. It returns with no header, does anyone know the probable reason?

Here is the code

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

# Prod is the df
my_numpy = prod.to_numpy()
np.savetxt(r'D:/Queries Claro/Dados_limpos.csv', my_numpy,fmt='%s', delimiter='|')

>Solution :

NumPy has no header names, so when you convert it from Pandas it loses the headers.
You can use instead:

prod.to_csv(r'D:/Queries Claro/Dados_limpos.csv', sep='|')
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