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
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. |