Read CSV File Data Into An Array Of Structs | C Programming Example

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

This is great! I and my friend are going to learn more C this summer. Now we’re dealing with finals. I shared the channel with my classmates and my friends. Your channel is a gem!

JH-uxre
Автор

Kevin, I can't say enough about this style of teaching how to program. I have a small library of books that come nowhere near this depth. I was suckered by the word "advanced" in their titles. I hate wasting time practicing writing B.S. snippets. I want/need to spend time writing code with utility, and that's what you do! I feel this knowledge will stick with me, and it definitely gives me a much better understanding of C. Thank you!

waynec
Автор

this is exactly what i needed for my programming class, thank you

sergiothethousandth
Автор

This tutorial is actually good stuff. Well done sir!

lestath
Автор

I looked through your video list and couldn't find one where you went back to this subject and made a more robust and generic CSV file reader. I would suggest that if you actually do so, you use a dynamic array of whatever objects you decide upon storing for each line. Maybe teach people to use the C11 strtok_s() function instead of the older strtok() and perhaps teach about unions and enums so you can select the type being stored. Perhaps when storing a string use the C23 function strdup() to copy the string being stored and demonstrate free() at the end. Just a thought.

anon_y_mousse
Автор

thankyou, i finally got the video, which I needed desparately.

Shreyas_Jaiswal
Автор

Excellent video thank you for your efforts and knowledge sharing!

diogenes_of_sinope
Автор

what if students characteristics were separated by '\n'???

rfycqls
Автор

Hi I have a similar project but my file is separated by one or more space(a). I want to store mine into struct array as well, how do I go about modifying this to account for the potential extra delimiter.
Thank you for your great work sir 🙏🏻🙏🏻

Babylinglingling
Автор

How would you go about using this code to make another simple program to then have options to sort by average, name or age?

HarjotSingh-kkyt
Автор

If your csv contained an array of strings like [one;two;three;four] how would the corresponding code in the typedef struct change? And how would this change how we read that part of the file into the struct?

jonnelson
Автор

Hi! great video, i have a question maybe you have an answer. If im reading with fscanf like you but there are some fields(columns) I dont want to save, do I have to put 2 commas together? It would be like in your example if you dont want to save the students age, would it be: fscanf(file, "%c, %49[^, ], , lf\n", ...) ?

Tizifuchi
Автор

Great code! Was wondering if there's a way to clear the structs for repeated use ?

chili
Автор

Great video.

I get a bug that the fscanf returns 0 all the time. I check the file load, and it is working fine. Any help would be appreciated.

yuchen
Автор

a file called "file.txt" with content:
U, Virat Kohli, 23, 95.6
U, Serena Williams, 22, 83.2
G, Wayne Gretzky, 19, 84.2
must be saved directly in the main folder of the project. If using Code Blocks then this text file must be in the same location of main.c

fifaham
Автор

Hi there, I have a CSV file that has commas and new lines within the fields between the comma delimiters. What should I do?

Julien-pdvs
Автор

What would happen in case that it’s not the average, instead of this, let’s put 5 or x tests ….
In this case you have to put each int? Or you can use an array with the numbers?

danielespitia
Автор

Hi, if there was a header line, how would i go about removing that first?

tommymao
Автор

Can we not take the integer values as a string while using fscanf? like can I use %49[^, ] for every value instead of %d, %lf and so on?

saboten
Автор

This example works great as long as all 4 variable types do not change. Try using this code using all string type variables. %c, %49[^, ], %d, %lf\n will fail very badly. Neither will the unwanted commas be parse or omitted from the output.

kspan-xjgs
visit shbcf.ru