Rust for the Novice Programmer/CSV Program
Making a Simple CSV Analysis Program
[edit | edit source]In this program, we will learn more about traits, including generics and become more comfortable with programming ideas like collections.
What is CSV?
[edit | edit source]CSV or comma separated values is a very simple file format for storing data in a file. Essentially as the name suggests it is just values separated with commas. Each line indicates a new set of values. The first line is headers, indicating what each value means. Here's an example to make it clearer:
Let's say we wanted to store video game characters' stats, we could use something like this:
ID,Attack,Defense,Health,Speed
1,10,20,25,5
2,30,10,10,30
3,40,40,10,10
4,10,40,50,5
Thus we would have 4 characters, our first character would have id: 1, attack: 10, defense: 20, health: 25, speed: 5. Our second character would have id: 2, attack: 30, defense: 10, health: 10, speed: 30. etc.
Program specifications:
[edit | edit source]- Will parse CSV values from a file and print out some stats about them
- Will feature simple methods for reading new records
- Will feature simple methods for writing new records