{"action":"created","issue":{"url":"https://api.github.com/repos/Charlotteis/noquestionistupid/issues/24","labels_url":"https://api.github.com/repos/Charlotteis/noquestionistupid/issues/24/labels{/name}","comments_url":"https://api.github.com/repos/Charlotteis/noquestionistupid/issues/24/comments","events_url":"https://api.github.com/repos/Charlotteis/noquestionistupid/issues/24/events","html_url":"https://github.com/Charlotteis/noquestionistupid/issues/24","id":57583263,"number":24,"title":"Help need with some text munging","user":{"login":"NeilCFord","id":1401378,"avatar_url":"https://avatars.githubusercontent.com/u/1401378?v=3","gravatar_id":"","url":"https://api.github.com/users/NeilCFord","html_url":"https://github.com/NeilCFord","followers_url":"https://api.github.com/users/NeilCFord/followers","following_url":"https://api.github.com/users/NeilCFord/following{/other_user}","gists_url":"https://api.github.com/users/NeilCFord/gists{/gist_id}","starred_url":"https://api.github.com/users/NeilCFord/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NeilCFord/subscriptions","organizations_url":"https://api.github.com/users/NeilCFord/orgs","repos_url":"https://api.github.com/users/NeilCFord/repos","events_url":"https://api.github.com/users/NeilCFord/events{/privacy}","received_events_url":"https://api.github.com/users/NeilCFord/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-02-13T10:34:28Z","updated_at":"2015-02-16T11:10:44Z","closed_at":null,"body":"I should know enough Python or Ruby (or shell commands for that matter) to do this, but I don't, hence the cry help.\r\n\r\nI have a 500+ line CSV file that contains for bits of information per line. One is a Twitter ID in the normal form of @twitterID. I need to transform that into a fully formed link of the format:\r\n\r\n    <a href=\"https://twitter.com/twitterID\">@twitterID</a>\r\n\r\nand either write it back out to the original file or to a new one, with the other data intact as well.\r\n\r\nWhist a Python or Ruby solution would be great, to further my education, right now I'll take any solution that works.\r\n\r\nThanks in advance for any and all assistance.\r\n\r\nNeil."},"comment":{"url":"https://api.github.com/repos/Charlotteis/noquestionistupid/issues/comments/74492597","html_url":"https://github.com/Charlotteis/noquestionistupid/issues/24#issuecomment-74492597","issue_url":"https://api.github.com/repos/Charlotteis/noquestionistupid/issues/24","id":74492597,"user":{"login":"nickcharlton","id":11917,"avatar_url":"https://avatars.githubusercontent.com/u/11917?v=3","gravatar_id":"","url":"https://api.github.com/users/nickcharlton","html_url":"https://github.com/nickcharlton","followers_url":"https://api.github.com/users/nickcharlton/followers","following_url":"https://api.github.com/users/nickcharlton/following{/other_user}","gists_url":"https://api.github.com/users/nickcharlton/gists{/gist_id}","starred_url":"https://api.github.com/users/nickcharlton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickcharlton/subscriptions","organizations_url":"https://api.github.com/users/nickcharlton/orgs","repos_url":"https://api.github.com/users/nickcharlton/repos","events_url":"https://api.github.com/users/nickcharlton/events{/privacy}","received_events_url":"https://api.github.com/users/nickcharlton/received_events","type":"User","site_admin":false},"created_at":"2015-02-16T11:10:44Z","updated_at":"2015-02-16T11:10:44Z","body":"I'd probably do something like this, in Ruby:\r\n\r\n(The `data` section is a [heredoc][], it's just a string.)\r\n\r\n```ruby\r\nrequire 'csv'\r\n\r\ndata = <<EOD\r\nSouth Australian Maritime Museum,@SAMaritimeMuseu,Australia,History\r\nMigration Museum,@MigrationMuseum,Australia,History\r\nSydney Living Museums,@sydlivmus,Australia,\"Architecture and heritage, Societies and civilisations\"\r\nCarnamah Historical Society & Museum,@carnamah,Australia,History\r\nSovereign Hill Museums Association,@GoldfieldsEd,Australia,\"History, Societies and civilisations, Technology and industry, Theater\"\r\nEOD\r\n\r\nCSV.parse(data) do |row|\r\n  name = row[1]\r\n  # take off the first '@' symbol by trimming the characters down\r\n  handle = name[1..-1]\r\n  \r\n  # build up the output\r\n  puts \"<a href=\\\"https://twitter.com/#{handle}\\\">#{name}</a>\"\r\nend\r\n```\r\n\r\nIf you were reading from a file, you'd be able to replace the CSV line like this:\r\n\r\n```ruby\r\nCSV.foreach(File.expand_path 'file_name.csv', __dir__) do |row|\r\n  # the block contents from above\r\nend\r\n```\r\n\r\n[heredoc]: http://en.wikipedia.org/wiki/Here_document"}}