{"id":141,"date":"2013-01-24T12:27:30","date_gmt":"2013-01-24T11:27:30","guid":{"rendered":"https:\/\/www.benscoat.eu\/?p=141"},"modified":"2020-11-27T12:28:08","modified_gmt":"2020-11-27T11:28:08","slug":"make-a-so-called-csv-a-real-csv","status":"publish","type":"post","link":"https:\/\/www.benscoat.eu\/index.php\/2013\/01\/24\/make-a-so-called-csv-a-real-csv\/","title":{"rendered":"Make a so-called csv a real csv"},"content":{"rendered":"\n<p>When you create csv files from the same systems than those which are not able to properly open them, you might need afterward to clean it up. I often find myself annoyed by so-called csv files that are actually delimited by semicolons, and commas are used as decimal separators. Here is a code to first replace commas by periods, then replace semicolons by commas.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"applescript\" class=\"language-applescript\">tell application \"Finder\" to set FileToEdit to selection as string\nset AccessToFile to open for access file FileToEdit with write permission\nset CSVContent to read file FileToEdit\nto switchText from t to r instead of s\nset d to text item delimiters\nset text item delimiters to s\nset t to t's text items\nset text item delimiters to r\ntell t to set t to item 1 &amp; ({\"\"} &amp; rest)\nset text item delimiters to d\nt\nend switchText\nswitchText from CSVContent to \".\" instead of \",\"\nset FirstStepText to result\nswitchText from FirstStepText to \",\" instead of \";\"\nset TextToWrite to result\nset eof of file FileToEdit to 0\nwrite TextToWrite to AccessToFile\nclose access AccessToFile<\/code><\/pre>\n\n\n\n<p>Credit goes to member kai (<a href=\"http:\/\/macscripter.net\/viewtopic.php?pid=41243#p41243\">http:\/\/macscripter.net\/viewtopic.php?pid=41243#p41243<\/a>).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When you create csv files from the same systems than those which are not able to properly open them, you might need afterward to clean it up. I often find myself annoyed by so-called csv files that are actually delimited by semicolons, and commas are used as decimal separators. Here is a code to firstContinue reading &rarr;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[],"_links":{"self":[{"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/posts\/141"}],"collection":[{"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/comments?post=141"}],"version-history":[{"count":1,"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/posts\/141\/revisions"}],"predecessor-version":[{"id":142,"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/posts\/141\/revisions\/142"}],"wp:attachment":[{"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/media?parent=141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/categories?post=141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/tags?post=141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}