Auto-detect CSV Separator
page 1 of 4
Published: 02 Aug 2011
Unedited - Community Contributed
Abstract
CSV files are very popular for storing tabular data because they are simple textual files with a very few rules. This makes them very interoperable because CSV readers and writers are relatively easy to implement. Interoperability is, probably, the first reason why would someone choose to save the data in CSV format. In order to build a generic CSV reader that will read CSV file regardless of the separator, the reader must first figure out which character is used as a separator. This article gives one possible solution to this problem.
by Josip Kremenic
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 24557/ 68

Introduction

Auto-detect CSV separator WPF application screenshot

CSV files are very popular for storing tabular data because they are simple textual files with a very few rules. This makes them very interoperable because CSV readers and writers are relatively easy to implement. Interoperability is, probably, the first reason why would someone choose to save the data in CSV format.

Although rules for writing and reading CSV files, which are explained in next chapter, are relatively known and widely accepted, one rule is an exception – determining a character that will be used as a separator. CSV files, as the name Comma Separated Values says, should use comma [,] as the separator but there are many CSV files that use semicolon [;] or horizontal tab [\t] as a separator.

So, in order to build generic CSV reader that will read CSV file regardless of the separator, reader must first figure out which character is used as a separator. This article gives one possible solution to this problem.


View Entire Article

User Comments

No comments posted yet.






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-10-15 11:41:21 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search