Reading CSV Files in C (with real-world data) -- No Need to Know How Many Lines Are There!

Reading CSV Files in C (with real-world data) -- No Need to Know How Many Lines Are There!

CompSci with Dr. Victor

54 года назад

991 Просмотров

One of the main uses of a program is to read in a large amount of data and do some data processing. What you have is a bunch of text in a file which your program is going to parse them into operable values so you can do some fancy arithmetic on them.

0:00 Intro
0:58 What is a Comma-Separated-Values (CSV) file
2:20 Tell the program to open a file using fopen
4:52 Read the file line-by-line as a Cstring using fgets
12:52 Read the whole file from using a while-loop
16:03 Extract values from a line using strtok
21:07 Parse text representations into numerical data type using atof

In this video I’m going to talk about how to read in data from a CSV file using C. I’ll explain what a CSV file is, and how to write your program in C that reads in the content and perform some simple data processing.

I'll use real-world data (I got the weather data from here: https://climate.weather.gc.ca/historical_data/search_historic_data_e.html) and show you some tips and tricks in extracting and parsing information.

Тэги:

#C_Programming #CSV_files
Ссылки и html тэги не поддерживаются


Комментарии: