Detect delimiter in data file


Are you aware of any function that would help automatically detect the delimiter/separator used in a ASCII data file?


Hi @pomchip,
The function data.table::fread() tries to automatically determine the separator used in a delimited file. The arguments sep= and sep2= give you some extra control.

Otherwise, you could write a function to read the file line-by-line using readLines() and then do character frequency analysis to see which is most likely to be the separator (especially if it is equally common on every line).


This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

Thanks DavoWW. That gives me a place to start.

Ideally I would like to find the magic function that would return only the value of the separator when called.

I am not looking for processing the data file with data.table, but I can trying to replicate the approach this package takes.