{"id":4967,"date":"2015-03-21T13:20:25","date_gmt":"2015-03-21T12:20:25","guid":{"rendered":"http:\/\/emilkirkegaard.dk\/en\/?p=4967"},"modified":"2015-03-21T13:20:52","modified_gmt":"2015-03-21T12:20:52","slug":"pasting-numbers-with-leading-zeros-into-spreadsheet-without-losing-the-zeros","status":"publish","type":"post","link":"https:\/\/emilkirkegaard.dk\/en\/2015\/03\/pasting-numbers-with-leading-zeros-into-spreadsheet-without-losing-the-zeros\/","title":{"rendered":"Pasting numbers with leading zeros into spreadsheet without losing the zeros"},"content":{"rendered":"<p>I found some interesting data in a PDF. I want to get it into R for statistical analysis. However, the author has removed the decimals. So, when I try to paste the numbers, spreadsheet software removes the leading zeros which it considers redundant. Googling this issue reveals that <a href=\"http:\/\/webapps.stackexchange.com\/questions\/30333\/paste-numbers-as-string-in-google-spreadsheet\">a<\/a> <a href=\"http:\/\/webapps.stackexchange.com\/questions\/35526\/leading-zeros-in-google-spreadsheet-automatically-removed\">number<\/a> of other people have a similar issue and that they haven&#8217;t found a good solution. For handling just a few cells, one can insert &#8216; in front which solves the issue. This doesn&#8217;t work for pasting data.<\/p>\n<p>Here&#8217;s what I did:<\/p>\n<ol>\n<li>Copy the table to a simple text editor, I use <a href=\"http:\/\/notepad-plus-plus.org\/\">notepad++<\/a>. Your editor must support regex.<\/li>\n<li>Use <a href=\"http:\/\/en.wikipedia.org\/wiki\/Regular_expression\">regex<\/a> to insert the decimal separator (, or . depending on your preference\/language).<\/li>\n<li>Copy the table to the spreadsheet.<\/li>\n<\/ol>\n<p>This works.<\/p>\n<p>In my case, I had a table that looks like this:<\/p>\n<p><a href=\"http:\/\/emilkirkegaard.dk\/en\/wp-content\/uploads\/table-no-decimal.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-4968\" src=\"http:\/\/emilkirkegaard.dk\/en\/wp-content\/uploads\/table-no-decimal-1024x280.png\" alt=\"table no decimal\" width=\"720\" height=\"197\" \/><\/a><\/p>\n<p>First, I OCR&#8217;d the table with <a href=\"https:\/\/en.wikipedia.org\/wiki\/ABBYY#ABBYY_FineReader\">ABBYY FineReader<\/a>. Then I fixed any possible OCR errors (there was 1). Then I copied it to notepad++. Then I used search replace with the following regex parameters: search=&#8221;(\\d\\d\\d)&#8221;, replace=&#8221;.\\1&#8243;. In normal language this means: find any sequence of 3 digits in the text. Replace this by a dot followed by whatever you found. So this finds e.g. &#8220;011&#8221; and replaces with &#8220;.011&#8221;.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I found some interesting data in a PDF. I want to get it into R for statistical analysis. However, the author has removed the decimals. So, when I try to paste the numbers, spreadsheet software removes the leading zeros which it considers redundant. Googling this issue reveals that a number of other people have a [&hellip;]<\/p>\n","protected":false},"author":17,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2089],"tags":[2122,2121],"class_list":["post-4967","post","type-post","status-publish","format-standard","hentry","category-programming","tag-regex","tag-spreadsheet","entry"],"_links":{"self":[{"href":"https:\/\/emilkirkegaard.dk\/en\/wp-json\/wp\/v2\/posts\/4967","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/emilkirkegaard.dk\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/emilkirkegaard.dk\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/emilkirkegaard.dk\/en\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/emilkirkegaard.dk\/en\/wp-json\/wp\/v2\/comments?post=4967"}],"version-history":[{"count":1,"href":"https:\/\/emilkirkegaard.dk\/en\/wp-json\/wp\/v2\/posts\/4967\/revisions"}],"predecessor-version":[{"id":4969,"href":"https:\/\/emilkirkegaard.dk\/en\/wp-json\/wp\/v2\/posts\/4967\/revisions\/4969"}],"wp:attachment":[{"href":"https:\/\/emilkirkegaard.dk\/en\/wp-json\/wp\/v2\/media?parent=4967"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/emilkirkegaard.dk\/en\/wp-json\/wp\/v2\/categories?post=4967"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/emilkirkegaard.dk\/en\/wp-json\/wp\/v2\/tags?post=4967"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}