Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changelog file: YAML vs JSON vs CSV [closed]

I am creating a simple Changelog lib in CodeIgniter that will basically log a message everytime someone adds, deletes, changes or publish a blog post. I will log messages in files by batches of 300. So every 301st message will go in a new file. At first I wanted to write the logs to simple .log files but then I got the idea to actually style the thing and I had to seperate each "attribute" of each message (ie: the user, the message, the type of the log, etc.). So .log files are out of the question since extracting the info would be a pain.

What is the most appropriate format for such a task? I already ruled out MySQL and XML because they are too heavy (especially considering that the log files won't exceed (about) 300 lines). I suggested YAML vs JSON vs CSV in the title, but is there yet a better alternative?

like image 613
Robert Audi Avatar asked Feb 01 '26 14:02

Robert Audi


1 Answers

I'd say it all depends on what you need/want to do with those files :

  • CSV has one advantage : it can be imported to Excel and such applications -- which might be usefull in some situations, to do reporting to a superior, for instance
  • JSON is readable in many languages, including Javascript ; but not easy to read by a human being ; and harder to modify "by hand"
  • And YAML is quite easy to read ; not hard to modify by hand ; but not sure about the availability of libraries to read it in several languages.


If you are in none of these situations :

  • must be readable
    • by a human being
    • in several programming languages
  • easy to modify
    • same notes

Then I guess all three formats will be OK ^^


Without knowing more, I would go with either CSV (for the import to Excel stuff), or JSON (for the portability reason).

like image 195
Pascal MARTIN Avatar answered Feb 04 '26 03:02

Pascal MARTIN



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!