Skip to content

Commit

Permalink
Expand readme with configuration options
Browse files Browse the repository at this point in the history
  • Loading branch information
fitnr committed May 26, 2017
1 parent 6528f8a commit 4c6b564
Showing 1 changed file with 82 additions and 3 deletions.
85 changes: 82 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ or this (JSON):

Additionally, DataConverter can convert between delimiters. By default, this includes commands to convert to CSV and TSV, and it's possible to add your own delimiter (create a `User.sublime-commands` file following the pattern in [`DataConverter.sublime-commands`](DataConverter.sublime-commands)).

### Configuration
Check out [`DataConverter.sublime-settings`](DataConverter.sublime-settings) for a documented list of options.

## Installation

### With Package Control
Expand All @@ -85,3 +82,85 @@ CSV containing Unicode characters aren't supported in the Sublime Text 2 version
## Contributing

Pull requests with additional formats are encouraged.

## Configuration

DataConverter reads the following options from your settings file (Preferences > Package Settings > DataConverter > Settings - User).

#### headers
Possible values: `"sniff"`, `true`, or `false`.
````
"headers": "sniff"
````
When true, the first row is always treated as the header row. When "sniff", DataConverter will sniff for headers (sniffing isn't perfect). When false, DataConverter will assume there are no headers, and use default headers (`[val1, val2, ...]`).

#### line_sep
Character or null
````
"line_sep": null
````
Newline character for output. Set to either a character or `null`. When `null`, DataConverter uses the OS line separator, which is `"\r"` in Windows.

#### dialects
Object
````
"dialects": {
"example": {
"delimiter": ",",
"quotechar": "\"",
"escapechar": "\\",
"doublequote": false
"skipinitialspace": false,
"strict": false,
"quoting": "QUOTE_MINIMAL"
}
}
````
Defines a dialect for the CSV reader. Check the python docs for a [description of how to define a dialect](https://docs.python.org/3.3/library/csv.html#dialects-and-formatting-parameters).

DataConverter will try to detect a dialect, but it may fail. Define a dialect with this setting and then tell DataConverter to use it with the `use_dialect` option.

Note that Python's csv reader is hard-coded to recognise either '\r' or '\n' as end-of-line, and ignores lineterminator.

#### use_dialect
String
````
"use_dialect": "example"
````
Mandate a dialect for DataConverter to use. Could be a dialect defined in your settings file, or one defined in the csv module ("excel", "excel_tab", "unix_dialect"). This may be useful for specifying custom commands in a `.sublime-commands` file.

#### html_utf8
Boolean
````
"html_utf8": true
````
Modern HTML served with a proper character encoding can accept UTF-8 characters. If you're using another charset for your html, set this to `false`. When `false`, the 'DataConverter: to HTML Table' function will escape non-ascii characters (e.g. `–` for –). (XML is always returned with escaped characters.)


#### delimiter
Character
````
"delimiter": ","
````
DataConverter will try to detect the delimiter used in your data. If it has a problem, it will fall back on this value. This must be one character long. Use `"\t"` for tab.

#### header_joiner
String
````
"header_joiner": "_"
````
For formats where keys can't have spaces, field names will be joined with this character. By default, an underscore is used, e.g. 'Col Name' becomes 'Col_Name'. An empty string is OK.

#### deselect_after
Boolean
````
"deselect_after": false
````
If `true`: after converting, deselects and moves the pointer to the top. If `false`: leaves selection(s) in place

#### default_variable
````
"default_variable": "DataConverter"
````
For some conversions (SQL, ASP), DataConverter must name the table or array being created. By default, it's called 'DataConverter', any string value is accepted.

0 comments on commit 4c6b564

Please sign in to comment.