Coding Gem #1.3: Parsing CSV Data as Lists in C#

Поделиться
HTML-код
  • Опубликовано: 27 окт 2024

Комментарии • 32

  • @kristhomas8295
    @kristhomas8295 3 года назад +3

    I cannot stress how good this was. You didn't leave anything out in my opinion, everything was explained beautifully. I came here with the intent to review something I thought I already knew, and left here learning a lot. Thanks!

  • @jmoreno7554
    @jmoreno7554 2 года назад +2

    One of the best walk throughs Ive ever watched.

  • @marcelobeani
    @marcelobeani 2 года назад +1

    You are a very good teacher, congrats man. It really worked for me.

  • @danielferrero211
    @danielferrero211 4 месяца назад

    Gracias por el video, me fue muy útil a pesar de que no domino el ingles perfectamente.

  • @adamonjourney3726
    @adamonjourney3726 3 года назад +3

    Thank you for this great tutorial. Again learned new things. Btw: in countries with comma-decimal numbers we have to use System.Globalization.CultureInfo.InvariantCulture to Convert DoubleNumbers... otherwise 49.0(string) will be converted to 490(!). exp.: double g = Convert.ToDouble(rawData[7], CultureInfo.InvariantCulture);

    • @ParametricCamp
      @ParametricCamp  3 года назад +2

      You are absolutely right, I have ran into this issue before, thanks for bringing it up!

    • @opafritzsche
      @opafritzsche 2 года назад

      @@ParametricCamp YOU ARE BRILLANT! This is exactly what i am searching for.
      *BUT* there is one Problem for me:
      i need this, inside a C# Form ( UI Form for Windows ) is there something to find on your channel?
      Also i have a *LOT* of data, 1 CSV String to be split = 71 special Colums.
      Than i have a not know Amount of rows.
      So i need 71 Lists with Special colum data
      + unknown amount of rows all contains 71 Lists.
      Did you think this will be possible, or is this just **TO MUCH** to split ?

  • @SharaPk
    @SharaPk 3 года назад +1

    You explained everything, I loved that, thank you :)

  • @AndreasDahl87
    @AndreasDahl87 2 года назад

    Great tutorial for hobby programmer :D Thanks a lot!

  • @bluefyr22
    @bluefyr22 3 года назад +2

    this was amazingly helpful! thank you. I've been trying to figure out how to pull csv data into an array that i could then randomize and output different combinations.

  • @leizedsanchez3521
    @leizedsanchez3521 2 года назад

    Excellent thanks!

  • @jacobgandrup9865
    @jacobgandrup9865 3 года назад

    Thank you for this awesome and really helpful video, big thumps up!!

  • @capitanrdc99
    @capitanrdc99 2 года назад

    thank you so much!!

  • @anhquantrannguyen20
    @anhquantrannguyen20 3 года назад

    Just want to say thank you for the lecture.
    I tried to repeat the example with a random csv file I took from Autodesk Revit Mechanical/ Piping family (US - metric). I couldn't convert string list with decimal number (i.e 12.987) to double although I checked the csv carefully by inserting it as data into Excel for observing.
    Finally, I have achieved it by using Double.Parse method with changing IFormatProvider formating to the "en-US". Things I have learned from Double.Parse method is I also can use Double.TryParse method to verify if there is an odd format in a row/ column list.

  • @jeodezman32
    @jeodezman32 2 года назад

    simple, pefrect.

  • @serj-nf7ll
    @serj-nf7ll 7 месяцев назад

    Tnx MAN!

  • @charudattabangal5123
    @charudattabangal5123 Год назад

    Thank you for this great video,but I have a question regarding scientific notation.
    My csv file contains scientific notations, so is there any way to get rid of those?

  • @arfaouiarij8938
    @arfaouiarij8938 Год назад

    Thank you for simplifying this ! However, I have a question : So if the csv file have more than one "table", meaning that more than one header. For example : Name , last name and underneath the data for those and then address and email and the corresponding data underneath. How do I do with that?

  • @josoeI
    @josoeI 3 года назад

    Thank you so much

  • @arturoordonez-hernandez8750
    @arturoordonez-hernandez8750 3 года назад

    Using C#'s verbatim (@"") strings is similar to HTML's tags.

  • @jeptho
    @jeptho Год назад

    Great video.
    I have a csv where a row contains a customer number, a price and a item number. If the customer has multiple items with the same item number, it displays in the csv as a line for each item.
    How would you sum the price for each customer, for each item.
    Example:
    Customernumber, 150.50, itemnumber1
    Customernumber, 300, itemnumber2
    Customernumber, 150.5, itemnumber1
    The result should be customernumber, 301.0, itemnumber1
    Customernumber, 300, itemnumber2
    Hope it makes sense.
    Thank you in advance 🤞🏼

  • @charliewhittaker1391
    @charliewhittaker1391 3 года назад

    Thanks for the tutorial dude! Do you know how to then sort these lists while keeping the data in the same columns?
    Many thanks

  • @haskell3702
    @haskell3702 Год назад

    What if the value contains the comma character?

  • @brehiner25
    @brehiner25 3 года назад

    As I can see, you are printing by column but how can I print a specific row?

  • @yaduvamshi9
    @yaduvamshi9 2 года назад

    How to print the data in another file rather than into console

  • @hugohuaman1487
    @hugohuaman1487 3 года назад

    But how can I make a sum ? I mean if int the list of double there are the values 1 2 3 and I want to sum these 3 values how can I do that ?

    • @adamonjourney3726
      @adamonjourney3726 3 года назад

      declare a variable SUM outside a loop and count in loop like: SUM += columnWithNumbers[i];

  • @hamzadamiel7224
    @hamzadamiel7224 3 года назад

    how do i read a row and then put it in a list that can allow me to access the individual elements in the row

    • @adamonjourney3726
      @adamonjourney3726 3 года назад

      Maybe you can use a jagged list like:
      static void Main()
      {
      // Read the contents of the CSV file (as lines into array)
      string[] rawLinesCSV = System.IO.File.ReadAllLines(@"C:\grades.csv");
      // Count lines
      var dataRows = rawLinesCSV.Count();
      string[][] jaggedArray = new string[dataRows-1][]; // without headerRow
      for (int i = 0; i < dataRows - 1; i++)
      {
      Console.WriteLine("i: " + i + " : rowData: " + rawLinesCSV[i + 1]);
      jaggedArray[i] = rawLinesCSV[i + 1].Split(',');
      }
      for (int i = 0; i < jaggedArray.Length; i++)
      {
      for (int j = 0; j < jaggedArray[i].Length; j++)
      {
      System.Console.Write("jaggedArray[{0}][{1}]: ", i,j);
      System.Console.WriteLine("{0}{1}", jaggedArray[i][j], j == (jaggedArray[i].Length - 1) ? "" : " ");
      }
      System.Console.WriteLine();
      }
      Console.ReadKey();
      }
      #####
      Output:
      jaggedArray[0][0]: Alfalfa
      jaggedArray[0][1]: Aloysius
      jaggedArray[0][2]: 123-45-6789
      jaggedArray[0][3]: 40.0
      jaggedArray[0][4]: 90.0
      jaggedArray[0][5]: 100.0
      jaggedArray[0][6]: 83.0
      jaggedArray[0][7]: 49.0
      jaggedArray[0][8]: D-
      jaggedArray[1][0]: Alfred
      jaggedArray[1][1]: University
      jaggedArray[1][2]: 123-12-1234
      jaggedArray[1][3]: 41.0
      jaggedArray[1][4]: 97.0
      jaggedArray[1][5]: 96.0
      jaggedArray[1][6]: 97.0
      jaggedArray[1][7]: 48.0
      jaggedArray[1][8]: D+
      and so on...

  • @rubeushagrid4131
    @rubeushagrid4131 2 года назад

    Csv is easy. Tell us about xlx

  • @aqilnoor2678
    @aqilnoor2678 Год назад

    Thank you, You made this easy to understand for me
    ruclips.net/user/sgaming/emoji/7ff574f2/emoji_u1f44d.png