csvtotsv(
csvtotsv(
COMMATEXT
)

The csvtotsv( function converts comma separated text into tab separated text.

Parameters

This function has one parameter:

commatext – text containing comma separated values.

Description

This function converts comma separated text into a tab separated text array. For example, suppose you have a text file named Directory.csv that contains data like this:

    "Adams, Dorothy",555-3000,dadams@gmail.com
    "Franklin, Mark",555-4822,mfranklin@hotmail.com
    "Smith, John",555-1212,jsmith@yahoo.com
    "Wilson, Judy",555-9324,jwilson@acme.net

This data can be read into a variable and converted to tab separated format:

    local phoneNumbers
    phoneNumbers=csvtotsv(fileload("Directory.csv"))

The phoneNumbers variable now contains the same data, but separated by tabs instead of commas. However, commas inside quotes have not been converted into tabs.

    Adams, Dorothy ▸ 555-3000 ▸ dadams@gmail.com
    Franklin, Mark ▸ 555-4822 ▸ mfranklin@hotmail.com
    Smith, John ▸ 555-1212 ▸ jsmith@yahoo.com
    Wilson, Judy ▸ 555-9324 ▸ jwilson@acme.net

The tab separated format, which doesn’t require quotes for commas, is much simpler to work with if you need to further process or display the data.

NOTE: Though usually this function takes input data with a comma character in between each exported field, a semicolon (`;`) is used instead if the System Preferences Language & Region panel specifies that the numeric decimal point character is set to a comma (as it is for many European countries) instead of a period. For example, in the United States this function will expect a comma between each imported field, while in France it will expect a semicolon (`;`). You can change this setting in the System Preferences Language & Region panel and Panorama will immediately change the import separator character – you don’t have to quit and relaunch Panorama.

See Also

- arrayfilter( -- processes each element of a text array or a data array with a formula (see Text Arrays and Data Arrays).
- Import Database -- importing another database into the current database.
- import( -- returns a line or element of imported data. This function works in conjunction with repetitive operations like importtext, arrayfilter(, characterfilter( etc.
- importcell( -- returns one cell of imported data.
- importdatabase -- imports data from another database into the current database.
- importjson -- imports a JSON array into the current database.
- importjsonline -- imports a JSON record into the current record.
- importline -- imports a line of text into the current record.
- importrawdata -- imports raw binary data into an existing database.
- importtext -- imports text into an existing database.
- newdatabasewithtextfieldnames -- creates a new database from a text file. The text file must contain the field names in the first line.
- partialdatabaseupdate -- updates one or more components of an existing database.
- seq( -- returns sequential numbers (1, 2, 3, etc.).
- Text Import -- importing text into an existing database.
- tsvtocsv( -- converts tab separated text into comma separated text.
- tsvtojson( -- converts tab separated text into JSON formatted text.

History

Version | Status | Notes
10.2 | Updated | Import separator character is now a semicolon (instead of a comma) if the system decimal point is a comma instead of a period.
10.0 | New | New in this version.