converting .data file to .csv using python | extrovert.dev -->

converting .data file to .csv using python

converting .data file to .csv using python
Tuesday, November 13, 2018


Datasets  are very essential part of data science. Simply you cannot go and create your own data using excel or someother ,ofcourse this would be better to increase skills & when you require data that doesnt support your model. Instead you find your data by some popular sources like

1. UCI
2.kaggle

Sometimes you may find the data in someother format like .data in this case . But you probably need a .csv file. There are different ways to do this.  But as a python lover you can use csv module to copy the files into csv format .


import csv

with open('sampledataset.data.txt') as input_file:
   lines = input_file.readlines()
   newLines = []
   for line in lines:
      newLine = line.strip().split()
      newLines.append( newLine )

with open('myset.csv', 'wb') as test_file:
   file_writer = csv.writer(test_file)
   file_writer.writerows( newLines )

0 Response to converting .data file to .csv using python

Comments are personally moderated by our team. Promotions are not encouraged.

Post a Comment