I have a large collection of DAT files that need to be converted (eventually to a unique file type). The DAT\'s have a mixed amount of whitespace between fields, and the column
This is answer for "Python - download and convert .dat to .csv [duplicate]". I couldn't post there so FYI you can get you exact output from here.
import urllib2
import csv
url = 'https://archive.ics.uci.edu/ml/machine-learning-databases/auto-mpg/auto-mpg.data'
response = urllib2.urlopen(url)
readData = response.read()
strObj = filter(None,readData.splitlines())
strObj = [w.replace('\t', ' ') for w in strObj]
listB = []
for i in strObj:
listB.append(filter(None,i.split(" ")))
with open(r'c:/data2.csv','a') as f:
writer = csv.writer(f)
writer.writerows(listB)