Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • 6
    Why bash? Python, able to read and write csv and json, would be a better choice for this task. Commented Jun 19, 2014 at 6:58
  • You could assume that the countries values end either when you see a new country (risky) or hit EOF (safe). Pre-sorting eliminates the risk if countries are always categorized in the correct region. The ambiguity is an issue with the provided data format. Commented Jun 19, 2014 at 7:09
  • 3
    Python, nodeJS, Perl would all better support data transformation between csv and json because of library availability. Commented Jun 19, 2014 at 7:10
  • Thanks for everyone's comments. The reason why I used BASH is because I do not know any other languages. I just picked up BASH doing my job.. I guess I know what to "pick up" next. Python :) Special Thanks for @David Atchley for the script... You are champion ! Commented Jun 20, 2014 at 7:28
  • and guys ...I am interested in knowing how it could be done in python... If someone could be kind enough to gimme a python script which does this, then it would be a great chance for me to pick up some python ... Commented Jun 21, 2014 at 10:51

lang-bash