{"id":986,"date":"2014-12-29T03:56:44","date_gmt":"2014-12-29T08:56:44","guid":{"rendered":"http:\/\/www.amibroker.com\/kb\/?p=986"},"modified":"2018-12-11T02:29:42","modified_gmt":"2018-12-11T01:29:42","slug":"importing-data-using-multiple-column-separators","status":"publish","type":"post","link":"https:\/\/www.amibroker.com\/wordpress\/kb\/2014\/12\/29\/importing-data-using-multiple-column-separators\/","title":{"rendered":"Importing data using multiple column separators"},"content":{"rendered":"

When we import data from ASCII (plain text) files, sometimes the data in the input files are arranged in columns separated by different characters. This article shows how to configure Import Wizard \/ ASCII Importer to import such data correctly.<\/p>

Let us consider data file using the following format<\/p>

Ticker,Date\/Time,Open,High,Low,Close,Volume
EURUSD,2011-06-13 20:19:00,1.4421,1.4421,1.4419,1.4419,332
EURUSD,2011-06-13 20:20:00,1.4419,1.4419,1.4418,1.4418,298
EURUSD,2011-06-13 20:21:00,1.4418,1.4418,1.4416,1.4417,192
<\/code><\/p>

In this sample data file columns are separated with a comma, with one exception – date and time columns are combined together, with a space in between. ASCII importer requires us to specify Date<\/strong> and Time<\/strong> columns separately. Fortunately – there is a way to treat space and comma both as separators at the same time.<\/p>

To configure Import Wizard<\/strong>, we need to specify columns to match the input data, treating Date<\/strong> and Time<\/strong> as two separate columns (Column 2 and Column 3 in this case), additionally we need to set Separator field as Comma or Space<\/strong>, so the importer would properly recognize space as a character delimiting the new column.<\/p>

\"Import<\/p>

This way our data will be imported properly. There are also other multiple separator choices available in the Import Wizard, such as Tab or Space<\/strong> and Semicolon or Space<\/strong> that can be used if your data file uses tabs or semicolons as primary column separator.<\/p>

If we build our import definition file manually for ASCII importer, we can also specify multiple separators, by enclosing the required characters in quotation marks in $SEPARATOR command. The equivalent format definition for the above input data would look like this:<\/p>

$FORMAT Ticker, Date_YMD, Time, Open, High, Low, Close, Volume
$SKIPLINES 1
$SEPARATOR \", \"
$CONT 1
$GROUP 255
$AUTOADD 1
$DEBUG 1
<\/code><\/p>

More information about ASCII importer and Import Wizard functionalities can be found in the manual:
http:\/\/www.amibroker.com\/guide\/w_impwizard.html<\/a>
http:\/\/www.amibroker.com\/guide\/d_ascii.html<\/a><\/p>","protected":false},"excerpt":{"rendered":"

When we import data from ASCII (plain text) files, sometimes the data in the input files are arranged in columns separated by different characters. This article shows how to configure Import Wizard \/ ASCII Importer to import such data correctly.Let us consider data file using the following formatTicker,Date\/Time,Open,High,Low,Close,VolumeEURUSD,2011-06-13 20:19:00,1.4421,1.4421,1.4419,1.4419,332EURUSD,2011-06-13 20:20:00,1.4419,1.4419,1.4418,1.4418,298EURUSD,2011-06-13 20:21:00,1.4418,1.4418,1.4416,1.4417,192In this sample data file […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[54,47],"_links":{"self":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/986"}],"collection":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/comments?post=986"}],"version-history":[{"count":2,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/986\/revisions"}],"predecessor-version":[{"id":1535,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/986\/revisions\/1535"}],"wp:attachment":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/media?parent=986"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/categories?post=986"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/tags?post=986"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}