{"id":3127,"date":"2019-03-25T17:42:49","date_gmt":"2019-03-25T20:42:49","guid":{"rendered":"http:\/\/xexeu.elipse.com.br\/pt\/automation-in-code-generation-lesson-3-changing-a-string-into-a-vector\/"},"modified":"2020-04-08T14:06:41","modified_gmt":"2020-04-08T17:06:41","slug":"automation-in-code-generation-lesson-3-changing-a-string-into-a-vector","status":"publish","type":"post","link":"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-3-changing-a-string-into-a-vector\/","title":{"rendered":"Automation in code generation: Lesson 3 &#8211; Changing a string into a vector."},"content":{"rendered":"<div align=\"justify\">\n<p>For the purposes of this article, we will consider option 1 from Lesson 2 is being used.<\/p>\n<p>After the <b>.csv<\/b> file has been read, we are left with a string that is equivalent to the contents of the whole table. Rows are separated by line breaks, and columns by either a semicolon (;) or a comma (,), depending on Windows country and language settings.<\/p>\n<p>Example:<\/p>\n<p><span style=\"font-family: Courier New;\">SE1;5201;Driver1;Tag1<br \/>\nSE1;5202;Driver1;Tag2<br \/>\nSE1;5203;Driver1;Tag3<br \/>\nSE2;5204;Driver2;Tag1<br \/>\nSE2;5205;Driver2;Tag2<br \/>\nSE2;5206;Driver2;Tag3<br \/>\nSE3;5207;Driver3;Tag1<br \/>\nSE3;5208;Driver3;Tag2<br \/>\nSE3;5209;Driver3;Tag3<\/span><\/p>\n<p>To separate data individually (cell by cell), you must turn the string into a vector. This can be done via vbScript&#8217;s <i>Split <\/i>method, which has one mandatory parameter and three optional ones:<\/p>\n<p><span style=\"font-family: Courier New;\">Split(expression[, delimiter[, count[, compare]]])<\/span><\/p>\n<p>The <span style=\"font-family: Courier New;\">expression <\/span>parameter must be replaced by the desired string. The <span style=\"font-family: Courier New;\">delimiter <\/span>parameter indicates which separator must be used. The other two parameters are not relevant to this case, and must therefore be left blank.<\/p>\n<p>Usage example:<\/p>\n<p><span style=\"font-family: Courier New;\">auxVetor = Split(auxString, vbNewLine)<\/span><\/p>\n<p>In this example, the <span style=\"font-family: Courier New;\">auxString <\/span>variable is the string equivalent to the spreadsheet&#8217;s content, and <span style=\"font-family: Courier New;\">vbNewLine <\/span>constant is the line break character.<\/p>\n<p>Now, <span style=\"font-family: Courier New;\">auxVetor <\/span>variable contains a vector with as many positions in it as the number of rows in the table:<\/p>\n<pre><span style=\"font-family: Courier New;\">auxVetor(0) contains the string \"SE1;5201;Driver1;Tag1\"\r\nauxVetor(1) contains the string \"SE1;5202;Driver1;Tag2\"\r\nauxVetor(2) contains the string \"SE1;5203;Driver1;Tag3\"<\/span><\/pre>\n<p>and so on.<\/p>\n<p>The next step is to separate each row&#8217;s column. To do so, you must scan all positions of the vector, and once again execute <i>Split <\/i>method, only this time passing a semicolon (;) as parameter.<\/p>\n<p>Example:<\/p>\n<pre><span style=\"font-family: Courier New;\"><span style=\"color: #339966;\">'separates the string into a row vector <\/span>\r\nauxVetor = split(auxString, vbNewline)<\/span>\r\n\r\n<span style=\"color: #339966;\">'for each row <\/span>\r\nfor i=0 to Ubound(auxVetor)\r\n\r\n<span style=\"color: #339966;\">'separates the row into a cell vector<\/span>\r\nvetorColunas = split(auxVetor(i), \";\")\r\n<span style=\"color: #339966;\">\r\n'saves the cells in script variables<\/span>\r\nauxSE = vectorColumns(0)\r\nauxEquip = vectorColumns(1)\r\nauxDriver = vectorColumns(2)\r\nauxTag = vectorColumns(3)\r\n\r\n<span style=\"color: #339966;\">\u00a0\u00a0 'here goes the rest of the automated script, which will use the data\r\n'organized above to create\/set up the desired objects\r\n'...\r\n'...\r\n'... <\/span>\r\n\r\nnext\r\n\r\n<\/pre>\n<p><b>NOTE<\/b>: The template to be used in the spreadsheet (which data will be saved, and in which order it will happen) can vary according to the user. Therefore, the sample script above will vary according to the defined template.<\/p>\n<\/div>\n<h3>Related articles<\/h3>\n<hr \/>\n<ul>\n<li><a href=\"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-introduction\/\">Automation in code generation: Introduction.<\/a><\/li>\n<li><a href=\"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-1-working-with-vectors\/\" target=\"_blank\" rel=\"noopener noreferrer\">Automation in code generation: Lesson 1 \u2013 Working with vectors.<\/a><\/li>\n<li><a href=\"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-2-reading-information-from-an-excel-file\/\" target=\"_blank\" rel=\"noopener noreferrer\">Automation in code generation: Lesson 2 \u2013 Reading information from an Excel file.<\/a><\/li>\n<li><a href=\"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-3-changing-a-string-into-a-vector\/\" target=\"_blank\" rel=\"noopener noreferrer\">Automation in code generation: Lesson 3 \u2013 Changing a string into a vector.<\/a><\/li>\n<li><a href=\"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-4-scanning-specific-objects-in-a-location\/\" target=\"_blank\" rel=\"noopener noreferrer\">Automation in code generation: Lesson 4 \u2013 Scanning specific objects in a location.<\/a><\/li>\n<li><a href=\"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-5-adding-objects-via-scripts\/\" target=\"_blank\" rel=\"noopener noreferrer\">Automation in code generation: Lesson 5 \u2013 Adding objects via scripts.<\/a><\/li>\n<li><a href=\"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-6-checking-for-preexisting-objects\/\" target=\"_blank\" rel=\"noopener noreferrer\">Automation in code generation: Lesson 6 \u2013 Checking for pre-existing objects.<\/a><\/li>\n<li><a href=\"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-7-events-for-script-execution\/\" target=\"_blank\" rel=\"noopener noreferrer\">Automation in code generation: Lesson 7 \u2013 Events for script execution.<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>For the purposes of this article, we will consider option 1 from Lesson 2 is being used. After the .csv file has been read, we are left with a string&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0},"categories":[763,825],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Automation in code generation: Lesson 3 - Automation in code generation: Lesson 3 - Changing a string into a vector.[:] - Elipse Knowledgebase<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-3-changing-a-string-into-a-vector\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Automation in code generation: Lesson 3 - Changing a string into a vector.\" \/>\n<meta property=\"og:description\" content=\"For the purposes of this article, we will consider option 1 from Lesson 2 is being used. After the .csv file has been read, we are left with a string&hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-3-changing-a-string-into-a-vector\/\" \/>\n<meta property=\"og:site_name\" content=\"Elipse Knowledgebase\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/www.facebook.com\/elipsesoftware\" \/>\n<meta property=\"article:published_time\" content=\"2019-03-25T20:42:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-04-08T17:06:41+00:00\" \/>\n<meta name=\"author\" content=\"Elipse Software\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Elipse Software\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-3-changing-a-string-into-a-vector\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-3-changing-a-string-into-a-vector\/\"},\"author\":{\"name\":\"Elipse Software\",\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/person\/def69ea453ea60b250497b89225a9f87\"},\"headline\":\"Automation in code generation: Lesson 3 &#8211; Changing a string into a vector.\",\"datePublished\":\"2019-03-25T20:42:49+00:00\",\"dateModified\":\"2020-04-08T17:06:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-3-changing-a-string-into-a-vector\/\"},\"wordCount\":764,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/kb.elipse.com.br\/#organization\"},\"articleSection\":[\"Scripts\",\"Elipse Power\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-3-changing-a-string-into-a-vector\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-3-changing-a-string-into-a-vector\/\",\"url\":\"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-3-changing-a-string-into-a-vector\/\",\"name\":\"[:pt]Automation in code generation: Lesson 3 - Changing a string into a vector.[:en]Automation in code generation: Lesson 3 - Changing a string into a vector.[:] - Elipse Knowledgebase\",\"isPartOf\":{\"@id\":\"https:\/\/kb.elipse.com.br\/#website\"},\"datePublished\":\"2019-03-25T20:42:49+00:00\",\"dateModified\":\"2020-04-08T17:06:41+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-3-changing-a-string-into-a-vector\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-3-changing-a-string-into-a-vector\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-3-changing-a-string-into-a-vector\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"In\u00edcio\",\"item\":\"https:\/\/kb.elipse.com.br\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Automation in code generation: Lesson 3 &#8211; Changing a string into a vector.\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/kb.elipse.com.br\/#website\",\"url\":\"https:\/\/kb.elipse.com.br\/\",\"name\":\"Elipse Knowledgebase\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/kb.elipse.com.br\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/kb.elipse.com.br\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/kb.elipse.com.br\/#organization\",\"name\":\"Elipse Software\",\"url\":\"https:\/\/kb.elipse.com.br\/\",\"sameAs\":[\"http:\/\/www.facebook.com\/elipsesoftware\"],\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/05\/schererelipse-com-br\/logoElipse.png\",\"contentUrl\":\"https:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/05\/schererelipse-com-br\/logoElipse.png\",\"width\":161,\"height\":58,\"caption\":\"Elipse Software\"},\"image\":{\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/person\/def69ea453ea60b250497b89225a9f87\",\"name\":\"Elipse Software\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ff1f7ec38f4687b06f6851d97b3cd2d0?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ff1f7ec38f4687b06f6851d97b3cd2d0?s=96&d=mm&r=g\",\"caption\":\"Elipse Software\"},\"url\":\"https:\/\/kb.elipse.com.br\/en\/author\/webmasterelipse-com-br\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Automation in code generation: Lesson 3 - Automation in code generation: Lesson 3 - Changing a string into a vector.[:] - Elipse Knowledgebase","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-3-changing-a-string-into-a-vector\/","og_locale":"en_US","og_type":"article","og_title":"[:pt]Automation in code generation: Lesson 3 - Changing a string into a vector.[:en]Automation in code generation: Lesson 3 - Changing a string into a vector.[:] - Elipse Knowledgebase","og_description":"For the purposes of this article, we will consider option 1 from Lesson 2 is being used. After the .csv file has been read, we are left with a string&hellip;","og_url":"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-3-changing-a-string-into-a-vector\/","og_site_name":"Elipse Knowledgebase","article_publisher":"http:\/\/www.facebook.com\/elipsesoftware","article_published_time":"2019-03-25T20:42:49+00:00","article_modified_time":"2020-04-08T17:06:41+00:00","author":"Elipse Software","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Elipse Software","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-3-changing-a-string-into-a-vector\/#article","isPartOf":{"@id":"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-3-changing-a-string-into-a-vector\/"},"author":{"name":"Elipse Software","@id":"https:\/\/kb.elipse.com.br\/#\/schema\/person\/def69ea453ea60b250497b89225a9f87"},"headline":"Automation in code generation: Lesson 3 &#8211; Changing a string into a vector.","datePublished":"2019-03-25T20:42:49+00:00","dateModified":"2020-04-08T17:06:41+00:00","mainEntityOfPage":{"@id":"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-3-changing-a-string-into-a-vector\/"},"wordCount":764,"commentCount":0,"publisher":{"@id":"https:\/\/kb.elipse.com.br\/#organization"},"articleSection":["Scripts","Elipse Power"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-3-changing-a-string-into-a-vector\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-3-changing-a-string-into-a-vector\/","url":"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-3-changing-a-string-into-a-vector\/","name":"[:pt]Automation in code generation: Lesson 3 - Changing a string into a vector.[:en]Automation in code generation: Lesson 3 - Changing a string into a vector.[:] - Elipse Knowledgebase","isPartOf":{"@id":"https:\/\/kb.elipse.com.br\/#website"},"datePublished":"2019-03-25T20:42:49+00:00","dateModified":"2020-04-08T17:06:41+00:00","breadcrumb":{"@id":"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-3-changing-a-string-into-a-vector\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-3-changing-a-string-into-a-vector\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/kb.elipse.com.br\/en\/automation-in-code-generation-lesson-3-changing-a-string-into-a-vector\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"In\u00edcio","item":"https:\/\/kb.elipse.com.br\/en\/"},{"@type":"ListItem","position":2,"name":"Automation in code generation: Lesson 3 &#8211; Changing a string into a vector."}]},{"@type":"WebSite","@id":"https:\/\/kb.elipse.com.br\/#website","url":"https:\/\/kb.elipse.com.br\/","name":"Elipse Knowledgebase","description":"","publisher":{"@id":"https:\/\/kb.elipse.com.br\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/kb.elipse.com.br\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/kb.elipse.com.br\/#organization","name":"Elipse Software","url":"https:\/\/kb.elipse.com.br\/","sameAs":["http:\/\/www.facebook.com\/elipsesoftware"],"logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/kb.elipse.com.br\/#\/schema\/logo\/image\/","url":"https:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/05\/schererelipse-com-br\/logoElipse.png","contentUrl":"https:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/05\/schererelipse-com-br\/logoElipse.png","width":161,"height":58,"caption":"Elipse Software"},"image":{"@id":"https:\/\/kb.elipse.com.br\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/kb.elipse.com.br\/#\/schema\/person\/def69ea453ea60b250497b89225a9f87","name":"Elipse Software","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/kb.elipse.com.br\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ff1f7ec38f4687b06f6851d97b3cd2d0?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ff1f7ec38f4687b06f6851d97b3cd2d0?s=96&d=mm&r=g","caption":"Elipse Software"},"url":"https:\/\/kb.elipse.com.br\/en\/author\/webmasterelipse-com-br\/"}]}},"_links":{"self":[{"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/posts\/3127"}],"collection":[{"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/comments?post=3127"}],"version-history":[{"count":4,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/posts\/3127\/revisions"}],"predecessor-version":[{"id":10534,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/posts\/3127\/revisions\/10534"}],"wp:attachment":[{"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/media?parent=3127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/categories?post=3127"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/tags?post=3127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}