Create CSV file in C# the EASY way | CsvHelper Tutorial

  Рет қаралды 33,336

Roberts Dev Talk

Roberts Dev Talk

Күн бұрын

Пікірлер: 43
@RDT
@RDT 3 жыл бұрын
We've now made an updated video that addresses some of your questions about handling semicolon delimiters and CSV files with no header row, check it out! kzbin.info/www/bejne/nGbFq4GebM2Jns0
@kelvindai1994
@kelvindai1994 2 жыл бұрын
Hi, i have a few question ?! 1. Let's say i have an Child Class named Fuel of RocketInfo ( Fuel : RocketInfo ), how do i write it to a csv file along side with the parent class ( RocketInfo ) ? 2. How do i read multiple .csv files in the same folder ?
@husseinadam4724
@husseinadam4724 Жыл бұрын
I am really liking this channel thank you Robert
@RDT
@RDT Жыл бұрын
Thanks for your support
@AlbrechtJ
@AlbrechtJ 3 жыл бұрын
Your example is awesome. Thanks for the CsvHelper series.
@RDT
@RDT 3 жыл бұрын
You’re welcome, glad you enjoyed it! I really like the library
@gatocode316
@gatocode316 4 ай бұрын
simple and direct, thanks.
@RDT
@RDT 4 ай бұрын
You're welcome!
@kopilkaiser8991
@kopilkaiser8991 2 жыл бұрын
Thanks for the video. I really pretty much understood everything you had shown and demonstrated.
@joffrelustosadoamaralmota6185
@joffrelustosadoamaralmota6185 2 жыл бұрын
Nice! An idea for some other video, is showing how to work with both mapped and dynamic columns.
@sofianell2557
@sofianell2557 3 жыл бұрын
Hello, please where does the newly created file goes ? Evrything compile OK, but i cannot find the file Thx
@patrickboehme4556
@patrickboehme4556 2 жыл бұрын
Awesome video, thanks!
@RDT
@RDT 2 жыл бұрын
Glad to hear you enjoyed it 😊
@badrulhussain5545
@badrulhussain5545 3 жыл бұрын
Hi is there a way to update the Environment.CurrentDirectory path. For example, if you have 3 projects in one solution and the 3rd project is a repository and you want the file to be saved in that 3rd project folder then the main project 1 that has the Controller?
@RDT
@RDT 3 жыл бұрын
Hi Badrul, I just used the Environment.CurrentDirectory as an example to keep things simple, but if you had multiple projects perhaps you could use a ..\ to switch between folders e.g. $"{Environment.CurrentDirectory}..\RepositoryProject"
@jamesallgood8506
@jamesallgood8506 3 жыл бұрын
nice video. is there any way to sort the column heads vertically instead of the default horizontal line? I cant seem to figure it out
@RDT
@RDT 3 жыл бұрын
As far as I can see, CsvHelper will always write column headers to the first line. However it does support writing dynamic/ExpandoObjects so you might be able to do something with that? You could create an IEnumerable populated with dynamically created objects that have the "column" name as the first property, and then add the other properties from your object after. That way the column names will be down the left hand side when you open up the file. If you then set the HasHeaderRecord = false on CsvConfiguration then it won't try to write a header line for you. Be careful when calling WriteRecords, make sure the type T on the IEnumerable is dynamic and not ExpandoObject, as it'll throw an exception. Hope that helps? Glad you enjoyed the video!
@jamesallgood8506
@jamesallgood8506 3 жыл бұрын
@@RDT Nvm, the PO just changed the requirment as of today, so I am good with the normal layout. But thanks a lot, anyway :)
@indreeshpandey2025
@indreeshpandey2025 2 жыл бұрын
hi, can u please make a video on state pattern ex like stopwatch
@harveyemmerson1568
@harveyemmerson1568 2 жыл бұрын
Is there a way to target specific cells, i am creating a little finance program and i need to change the users balance that is stored within the CSV file, is there a way i can target just that specific cells when writing records?
@egorzh3828
@egorzh3828 3 жыл бұрын
Hi, please tell me how to change the delimiter?
@RDT
@RDT 3 жыл бұрын
Hi EgorZH, thanks for your comment. You can change the delimiter by creating a new CsvConfiguration object and setting the Delimiter property, then passing that into the CsvWriter constructor instead of CultureInfo. I'll be uploading a new video soon which addresses this and a few other viewer questions :)
@egorzh3828
@egorzh3828 3 жыл бұрын
@@RDT Thanks
@AeroTesting
@AeroTesting Жыл бұрын
Hi you can help me! i'm trying save .csv but first i Open .DAT File -> .csv save format! can you help?
@indreeshpandey2025
@indreeshpandey2025 2 жыл бұрын
hi, can u please tell how to find the average of the payload capacity?
@RDT
@RDT 2 жыл бұрын
You could use the built in .NET Linq methods. Select to get an enumerable of the Payload capacity column and then Enumerable.Average
@favela9348
@favela9348 3 жыл бұрын
Hello, Thanks for the video, I have a problem with this line " return rocket.PayloadCapacity.HasValue ? $"{rocket.PayloadCapacity} kg" : String.Empty; " I don't know why I have this error : CS1061 'ConvertToStringArgs ' does not contain a definition for 'PayloadCapacity' and no accessible extension method 'PayloadCapacity' accepting a first argument of type 'ConvertToStringArgs ' was not found (a using directive or a reference assembly missing?) Can you help me :) Thanks
@favela9348
@favela9348 3 жыл бұрын
And it's possible to display an array ?
@PaoloBoffi
@PaoloBoffi 3 жыл бұрын
Hi, I don't know why but even following all the steps you have made my data are all inside the first element of the row in the .csv file, and not one for each column as in your example. Could you please help me?
@RDT
@RDT 3 жыл бұрын
Hi Paolo, is your source file formatted OK? Are you using dynamics or a custom class with attributes/classmap?
@PaoloBoffi
@PaoloBoffi 3 жыл бұрын
@@RDT hi, I managed yo solve. It was a problem with Excel, that I used to open the .csv file. It saw ";" as delimitation and not ","
@RDT
@RDT 3 жыл бұрын
That’s great, happy to hear you got it sorted. You can also set the delimiter CsvHelper uses in Configuration
@PaoloBoffi
@PaoloBoffi 3 жыл бұрын
@@RDT thank you again for your help :) And thank you for your videos :)
@RDT
@RDT 3 жыл бұрын
You’re welcome!
@cirilla7283
@cirilla7283 3 жыл бұрын
thanks
@RDT
@RDT 3 жыл бұрын
You're welcome!
@willchen5895
@willchen5895 2 жыл бұрын
is this .net 5.0 ?
@RDT
@RDT 2 жыл бұрын
This example was 3.1 github.com/chrismroberts/csvwriter-example/blob/main/CsvWriterDemo.csproj
Intro to the CsvHelper Library for C#
27:12
IAmTimCorey
Рет қаралды 30 М.
Forget Controllers and Minimal APIs in .NET!
14:07
Nick Chapsas
Рет қаралды 82 М.
Tuna 🍣 ​⁠@patrickzeinali ​⁠@ChefRush
00:48
albert_cancook
Рет қаралды 148 МЛН
My scorpion was taken away from me 😢
00:55
TyphoonFast 5
Рет қаралды 2,7 МЛН
The Best Band 😅 #toshleh #viralshort
00:11
Toshleh
Рет қаралды 22 МЛН
Creating Excel Files in C#
55:42
IAmTimCorey
Рет қаралды 130 М.
why do header files even exist?
10:53
Low Level
Рет қаралды 455 М.
10 Signs Your Software Project Is Heading For FAILURE
17:59
Continuous Delivery
Рет қаралды 34 М.
How to Load a CSV File to a DataGrid in WPF
15:32
Tactic Devs
Рет қаралды 3,6 М.
How to Parse JSON Data in C# - Coding Gems
16:52
ParametricCamp
Рет қаралды 41 М.
AI Is Making You An Illiterate Programmer
27:22
ThePrimeTime
Рет қаралды 239 М.
How To Create Generics in C#, Including New Features
38:51
IAmTimCorey
Рет қаралды 54 М.
Awesome Things You Can Build With C#  | Why Learn C# ?
7:11
Roberts Dev Talk
Рет қаралды 40 М.
10 C# Libraries To Save You Time And Energy
33:59
IAmTimCorey
Рет қаралды 209 М.