{"id":1311,"date":"2013-03-23T18:36:57","date_gmt":"2013-03-23T16:36:57","guid":{"rendered":"http:\/\/www.ozalto.com\/?p=1311"},"modified":"2013-11-07T15:37:10","modified_gmt":"2013-11-07T13:37:10","slug":"csv-carriage-returns-issues","status":"publish","type":"post","link":"https:\/\/www.ozalto.com\/en\/csv-carriage-returns-issues\/","title":{"rendered":"CSV &#038; Carriage returns issues"},"content":{"rendered":"<p><strong>Any datamerge user has faced this issue :<\/strong> one &#8220;cell&#8221; has\u00a0<strong>a carriage return<\/strong> (Ex: a two lines adress) but while datamerging with InDesign, <strong>everything goes wrong<\/strong> ! Informations are misused or even disappearing. But all your data is right within your table software. A single carriage return has corrupted the the data processing of the CSV\/TXT File by InDesign. <strong>Small issue but dramatic consequences.<\/strong><\/p>\n<hr \/>\n<h4>What&#8217;s wrong ?<\/h4>\n<br class=' sb-br' \/>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_CaptureTableur.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-1301\" title=\"CSV_CaptureTableur\" alt=\"CSV Capture Tableur\" src=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_CaptureTableur.png\" width=\"450\" height=\"97\" srcset=\"https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_CaptureTableur.png 450w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_CaptureTableur-300x64.png 300w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_CaptureTableur-120x25.png 120w\" sizes=\"(max-width: 450px) 100vw, 450px\" \/><\/a><\/p>\n<p>Let&#8217;s take this simple table. For our &#8220;adress&#8221; field, <strong>we typed in three lines of text<\/strong>. Let&#8217;s drop some tags for the demo :<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_Demo_template.png\"><img decoding=\"async\" class=\"aligncenter  wp-image-1303\" title=\"CSV_Demo_template\" alt=\"CSV Demo emplate\" src=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_Demo_template.png\" width=\"467\" height=\"227\" srcset=\"https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_Demo_template.png 584w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_Demo_template-300x145.png 300w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_Demo_template-530x257.png 530w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_Demo_template-120x58.png 120w\" sizes=\"(max-width: 467px) 100vw, 467px\" \/><\/a><\/p>\n<p>As we require a preview, we can see that something is definitively wrong.<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_Demo_resultat.png\"><img decoding=\"async\" class=\"aligncenter  wp-image-1302\" title=\"CSV_Demo_resultat\" alt=\"\" src=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_Demo_resultat.png\" width=\"478\" height=\"226\" srcset=\"https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_Demo_resultat.png 598w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_Demo_resultat-300x141.png 300w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_Demo_resultat-530x250.png 530w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_Demo_resultat-120x56.png 120w\" sizes=\"(max-width: 478px) 100vw, 478px\" \/><\/a><\/p>\n<p>The &#8220;society&#8221; field doesn&#8217;t show up within our layout. Even worse, on the next input, it&#8217;s gone mad :<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_Demo_resultat2.png\"><img decoding=\"async\" class=\"aligncenter  wp-image-1304\" title=\"CSV_Demo_resultat2\" alt=\"\" src=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_Demo_resultat2.png\" width=\"467\" height=\"230\" srcset=\"https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_Demo_resultat2.png 584w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_Demo_resultat2-300x147.png 300w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_Demo_resultat2-530x261.png 530w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_Demo_resultat2-120x60.png 120w\" sizes=\"(max-width: 467px) 100vw, 467px\" \/><\/a><\/p>\n<p>For most of you, we are just stating the obvious. Once that said, we wanted to offer a deeper explanation of the issue. InDesign does wrong because the <strong>carriage returns hosted within the cell were considered as a jump towards the next record<\/strong>. The string next to the carriage return is now considered as the first cell of the next row.<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_DemoWhy.png\"><img decoding=\"async\" class=\"aligncenter  wp-image-1305\" title=\"CSV_DemoWhy\" alt=\"\" src=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_DemoWhy.png\" width=\"520\" height=\"157\" srcset=\"https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_DemoWhy.png 743w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_DemoWhy-300x90.png 300w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_DemoWhy-530x159.png 530w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/CSV_DemoWhy-120x36.png 120w\" sizes=\"(max-width: 520px) 100vw, 520px\" \/><\/a><\/p>\n<hr \/>\n<h4>A fake good idea<\/h4>\n<br class=' sb-br' \/>\n<p>We thought we found a\u00a0<strong>solution<\/strong> to this issue thanks to a nice\u00a0<strong>algorithm<\/strong>. <strong>A really simple axiom<\/strong> : <strong>get the number of columns and check that every rows enumerate the right amount of cells<\/strong>\u00a0by merging lines and temporarly replace problematic carriage returns with a unique string to be replaced later within InDesign.<\/p>\n<p><a href=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/algorithme1.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-1307\" title=\"algorithme\" alt=\"algorithme\" src=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/algorithme1.png\" width=\"450\" height=\"238\" srcset=\"https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/algorithme1.png 450w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/algorithme1-300x158.png 300w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/algorithme1-113x60.png 113w\" sizes=\"(max-width: 450px) 100vw, 450px\" \/><\/a><\/p>\n<p>In the above figure, the first row only hosts two &#8220;cells&#8221; when there should be three. We then merge the rows 1 &amp; 2 to to get a three cells row. That&#8217;s the main concept. While the first trials were very enjoying, we had to face the awful truth. <strong>Our cooking won&#8217;t work everytime.<\/strong> Indeed, <strong>given how data would be found, it was almost impossible to reconstruct all the lines accurately.<\/strong><\/p>\n<p><a href=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/algorithmeIssue.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-1308\" title=\"algorithmeIssue\" alt=\"\" src=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/algorithmeIssue.png\" width=\"450\" height=\"238\" srcset=\"https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/algorithmeIssue.png 450w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/algorithmeIssue-300x158.png 300w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/03\/algorithmeIssue-113x60.png 113w\" sizes=\"(max-width: 450px) 100vw, 450px\" \/><\/a><\/p>\n<p><strong>Considering the red row cell, can we tell if it&#8217;s related to the orange cell or a separate cell within the row ?\u00a0<span style=\"color: #ff0000;\">No we can&#8217;t !!<\/span><\/strong><\/p>\n<hr \/>\n<h4>Conclusion<\/h4>\n<br class=' sb-br' \/>\n<p><strong>So it seems impossible to deal with carriage returns within a CSV\/TXT file<\/strong> because sooner or later, there will be some scenario where only the human brain can tell. That&#8217;s why InDesign can&#8217;t take them into account and so many editors working with CSV. And we won&#8217;t do better.<\/p>\n<p><strong>What else then ?<\/strong>\u00a0If you want to stick to datamerge, you will <strong>have to replace carriage returns within your source tables<\/strong> ( Excel files\u2026 ). Just check that a carriage return within your file is nothing but a jump towards a next row. You can use an unique string like ##RC## or any other pattern you won&#8217;t find within your data.<\/p>\n<p>Another solution would be to\u00a0<strong>prefer the XML format<\/strong> which can deal with carriage returns. <strong>But if you do use another technique, let us know.<\/strong><\/p>\n<p>Loic<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Any datamerge user has faced this issue : one &#8220;cell&#8221; has\u00a0a carriage return (Ex: a two lines adress) but while datamerging with InDesign, everything goes wrong ! Informations are misused or even disappearing. But all your data is right within your table software. A single carriage return has corrupted the the data processing of the [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":1310,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/posts\/1311\/"}],"collection":[{"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/posts\/"}],"about":[{"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/types\/post\/"}],"author":[{"embeddable":true,"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/users\/2\/"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/comments\/?post=1311"}],"version-history":[{"count":0,"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/posts\/1311\/revisions\/"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/media\/1310\/"}],"wp:attachment":[{"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/media\/?parent=1311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/categories\/?post=1311"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/tags\/?post=1311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}