Data Science Asked by Paul palmer on July 22, 2021
I’m using a data called ‘adults.data’, I need to work with that data as a ‘.csv’ file. Can anyone guide me on how can I change the format?
I tried opening the file in excel and then save it as csv, but the new file contains only one column containing all the ‘.data’ columns.
One way is to convert .data file to excel/csv using Microsoft Excel which provides an option to get external data (use Data tab --> from Text). Check this video for demo
Other way you can utilize python to read .data files and directly work with dataframes
import pandas as pd
df = pd.read_csv("adults.data")
(OR)
df = pd.read_table("adults.data")
Correct answer by Archana David on July 22, 2021
Another solution is to use pandas to read the file and then export it to an excel form as following:
import pandas as pd
df = pd.read_csv("file.data", sep=",", header=None)
df.to_excel("output.xlsx")
You could read more here
Answered by Hamzawi on July 22, 2021
This might helps you
. example:
pp = pd.read_excel('paul_palmer.xlsx')
pp.to_csv('paul_palmer.csv', index=False)
Answered by HARI on July 22, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP