...

/

CSV Files

CSV Files

Learn how to read and write CSV files in Go.

CSV is one of the most common data sources that a DevOps engineer can encounter. This simple format has long been a mainstay in the corporate world as one of the easiest ways to export data out of a system for manipulation and back into a data store.

Many critical systems at large cloud providers, such as Google’s GCP and Microsoft’s Azure, have critical data sources and systems based on the CSV format. We have seen systems such as network modeling and critical data reporting stored in CSV.

Data scientists love CSV for its easy searching and streaming capabilities. The added quality of being able to quickly visualize the data in software has only added to its appeal.

And, like many other formats, it is human-readable, which allows the data to be manipulated by hand.
In this lesson, we are going to focus on importing and exporting CSV data using the following:

  • The strings package and the bytes package

  • The encoding/csv package

Additionally, we are going to look at importing and exporting data to the popular Excel spreadsheet format using excelize, which is a popular package for Microsoft Excel. Now, let's discuss how we can use simple string/byte manipulation packages to read/write CSV files.

Basic value separation using the strings package

Go provides several packages that we'll find useful in the manipulation of the string and []byte types: ...