Wednesday, 15 July 2015

python - How to get the system wide list separator on Windows -



python - How to get the system wide list separator on Windows -

i utilize pandas convert csv more usable datatypes. problem csv files doesn't need separated commas. separator (between cells) defined operating scheme (at to the lowest degree under windows), , when scheme wide list separator differs comma, pandas (or else tried) cannot determine separator should used. sure, can create twocell csv file pywin or something, , separator, isn't there direct way this?

below can see txt representation of 2 csv files, displayed identically on windows machines, respectively "," , ";" default list separators.

test,1,2,"my name bond, james bond",my age is; 41 test;1;2;my name bond, james bond;"my age is; 41"

use python's built in sniffer class observe csv's delimiters. here's illustration from docs:

with open('example.csv', 'rb') csvfile: #detect delimiter used dialect = csv.sniffer().sniff(csvfile.read(1024)) #return origin of file csvfile.seek(0) #file should open right delimiter. reader = csv.reader(csvfile, dialect)

python csv pandas pywin32

No comments:

Post a Comment