Handle any CSV file with the CSV Buffer in AL and Business Central

Ғылым және технология

(*) And yes, CSV is hard to pronounce, so sometimes it comes out as CVS :)
Find more information at my blog www.hougaard.com or follow me on / ehougaard
Source code can be found here: github.com/hougaard/KZread-V...

Пікірлер: 43

  • @streichersit
    @streichersit2 ай бұрын

    3 years on and still solving problems! I just used this technique to import some data that required special processing.

  • @tamassoltesz5901
    @tamassoltesz5901 Жыл бұрын

    Fist of all thank you for your great work! I just wanted to add some comment to help your channel and second is that I am new to BC and I strogeld to find how to sal the TAB as separator because the parameter only accepts text[1]. So here is the trick I used: take a variable as Char (tabChar) and then assigne the value 9 (tabChar := 9) to it and than a format this for the precedure (format(tabChar))

  • @henrikfrederiksen5863
    @henrikfrederiksen58633 жыл бұрын

    Hi Erik, Big thanx for all your wonderful videos - really helping me getting into the Cloud World of BC! Could the Import of CSV be done without dialog. My customer has 4 csv files updated daily from their Vendor - and need them imported automatically every morning without user doing anything. Is it possible without using Azure - just using AL?

  • @Hougaard

    @Hougaard

    3 жыл бұрын

    That's hard, but I have made a simple solution, check out BCCL @ www.hougaard.com/bccl

  • @Hougaard

    @Hougaard

    3 жыл бұрын

    All other solutions are based on using webservices and communication somehow, either expose a webservice and call that from something else, or place the files in a spot where it can be accessed with a http client call from within BC (and then called from Job queue)

  • @DmitryKatson
    @DmitryKatson2 жыл бұрын

    Hey, in addition to that now there is a CSVBuffer.LoadDataFromStream(CSVInStream: InStream; CSVFieldSeparator: Text[1]; CSVCharactersToTrim: Text) - this will automatically trim characters like " during the loading process

  • @sheikhmuhammadsaqib-cp

    @sheikhmuhammadsaqib-cp

    4 ай бұрын

    Erik mentioned in the video that he will create a pull request for this.

  • @scottsteffen1434
    @scottsteffen14343 жыл бұрын

    As a newbie to this AL world, this was very helpful. Just wondering if you could give any insight to handling this same type of import but with 2 files (1 header, 1 detail lines). Here is my thinking... 1) Process Header Lines 2) Process Detail Lines ??

  • @Hougaard

    @Hougaard

    3 жыл бұрын

    In CSV terms, a header is just a line at the beginning, simply start at line number 2.

  • @dyongrob5744
    @dyongrob574411 ай бұрын

    Question, my CSV is different to yours in a way that it could only contain 1 SH but also multiple (seperate SL's). What i am looking for is to check if the SH already exists, and if so add the lines to the existing SH, but if it doesn't then create a new SH, i couldn't find a video about this on your account.

  • @Hougaard

    @Hougaard

    11 ай бұрын

    That you gotta code yourself out of, a multi-table csv can be a complicated thing to navigate.

  • @dyongrob5744

    @dyongrob5744

    11 ай бұрын

    @@Hougaard Would it be a multi table? since i think yours is too, my csv looks something like this: headers being : "Order No. (salesHeader)", "Line No. (salesLines)" , "Posting Date (salesHeader)", "Customer No. (salesHeader)", "Item No (salesLines)", "Quantity (salesLines)" "V-RE242763",660000,"31.03.2023",12101,"1001",5 "V-RE242763",670000,"31.03.2023",12101,"1002",1 "V-RE242764",680000,"31.03.2023",12101,"1002",1 It looks likes yours only difference is that i could have 2 lines for the salesLines instead of 1, or am i seeing this wrong?

  • @tonyhaines5125
    @tonyhaines51252 жыл бұрын

    How do we handle text qualifiers that are present within the CSV file in cases where we don't have an option to dictate/change the delimiters? As an example: "My Company, LLC", "Smith, John"

  • @Hougaard

    @Hougaard

    2 жыл бұрын

    In newer versions you can specify the delimiter.

  • @kenozakesy2372

    @kenozakesy2372

    2 жыл бұрын

    ​@@Hougaard Which newer version If I may ask. Could you specify that? Also do you have an example or documentation as I cannot find it.

  • @janholstbakkensen
    @janholstbakkensen3 жыл бұрын

    Hi Erik An alternative to the CSV Buffer could be using the List of ]Text] then you don't have the limitation of the length (Text[250]) var InStream: InStream; RecordText: Text; FieldList: List of [Text]; while not (InStream.EOS) do begin Clear(FieldList); InStream.ReadText(RecordText); FieldList := RecordText.Split(';'); // You will get a dynamic array with all values for each line DoSomethingWithTheFieldList(FieldList); end; i would suggest that you could make a similar video :)

  • @Hougaard

    @Hougaard

    3 жыл бұрын

    But split would fail on a line with the split char inside quotes..

  • @janholstbakkensen

    @janholstbakkensen

    3 жыл бұрын

    @@Hougaard The same will happen, when I use the CSV Buffer

  • @alainkrikilion5444
    @alainkrikilion54443 жыл бұрын

    Which extension is that lets you click on a .app and shows you the objects in it and opens also the object? 😮 You did that around 4:18. PS I didn't even know that there was also a CSV buffer...😓

  • @Hougaard

    @Hougaard

    3 жыл бұрын

    That's the AZ AL extension github.com/anzwdev/al-code-outline

  • @alainkrikilion5444

    @alainkrikilion5444

    3 жыл бұрын

    @@Hougaard Thanks. But I have that extension already, but when I click on a .app file, it doesn't show me the object list. I can show the object list with "Show all Project Symbols" but when I click to show definition, it asks me the launch configuration but fails. Strange...

  • @Hougaard

    @Hougaard

    3 жыл бұрын

    Strange, perhaps check in with the author Andrzej on twitter twitter.com/anzwdev

  • @miljanamladenovic1909
    @miljanamladenovic1909 Жыл бұрын

    Procedure WriteToStream has two parameters (5:59) . Then, where the variable GetNumberOfColumns came from? Thx

  • @Hougaard

    @Hougaard

    Жыл бұрын

    That's a function, sloppy coding to call function without parentesens...

  • @madhavadhatrao3528
    @madhavadhatrao3528 Жыл бұрын

    Hi Erik I am new in AL ,there is any book for me for learning step by step all the things

  • @Hougaard

    @Hougaard

    Жыл бұрын

    Try this github.com/mynavblog/ALForBeginners

  • @madhavadhatrao3528

    @madhavadhatrao3528

    Жыл бұрын

    @@Hougaard Thank you so much

  • @madhavadhatrao3528

    @madhavadhatrao3528

    Жыл бұрын

    @@Hougaard i have completed this file .if anything advance for me plz give me

  • @blutkraehe_official
    @blutkraehe_official3 жыл бұрын

    hi, in the guthub, i cannot find the source code for the table CSV Buffer, only for the Page...

  • @Hougaard

    @Hougaard

    3 жыл бұрын

    CSV Buffer is in the base app

  • @blutkraehe_official

    @blutkraehe_official

    3 жыл бұрын

    @@Hougaard i cannot find and I become a error 'Table ''"CSV Buffer"' is missing

  • @Hougaard

    @Hougaard

    3 жыл бұрын

    What version?

  • @blutkraehe_official

    @blutkraehe_official

    3 жыл бұрын

    @@Hougaard { "id": "05f93e9f-2636-43a0-b5bf-fb49820584f8", "name": "CSV_Import", "publisher": "Default publisher", "version": "1.0.0.0", "brief": "", "description": "", "privacyStatement": "", "EULA": "", "help": "", "url": "", "logo": "", "dependencies": [], "screenshots": [], "platform": "17.0.0.0", "application": "17.0.0.0", "idRanges": [ { "from": 50100, "to": 50149 } ], "contextSensitiveHelpUrl": "CSV_Import.com/help/", "showMyCode": true, "runtime": "6.0" }

  • @blutkraehe_official

    @blutkraehe_official

    3 жыл бұрын

    17 i think

  • @YannSaintLaurent
    @YannSaintLaurent Жыл бұрын

    Has anyone ever reported the bug in AL when using the CSV Buffer where a field with a comma in it like the number "10,000", will get processed as 2 fields.... 10 and 000. Microsoft has added a CharactersToTrim parameter since this video was created so that you can ask the CSV Buffer to remove double quotes but they process the characterToTrim after they've populated the value in the CSV Buffer.

  • @Hougaard

    @Hougaard

    Жыл бұрын

    There's an overload to the LoadData* methods where you can specify the separator character.

  • @YannSaintLaurent

    @YannSaintLaurent

    Жыл бұрын

    @@Hougaard yes, i did find that but it doesn’t work unfortunately. I tested and step through the code with the debugger but Microsoft looks for the next “separator” (comma) without caring about the CharactersToTrim.

  • @sendit2jason

    @sendit2jason

    2 күн бұрын

    @@YannSaintLaurent @Hougaard It's still a problem as I have just discovered in v24.1. Example: "Col1Value,with some more data","Col2Value" will load into CSV Buffer as 3 columns! Grrrr!

  • @weixiangow7156
    @weixiangow71562 жыл бұрын

    Can do video of csv buffer export it would be great help 👍

  • @georgewigglesworth1644

    @georgewigglesworth1644

    2 жыл бұрын

    Hi Erik, thanks for all your videos, they are brilliant - and your book, that is brilliant too. Can you do a book on the technical aspects covered in your videos - I'd buy it!! Anyway, the main point of my comment is I would love to see how to create a csv file from the CSV buffer table. Once you led us all the way with the import, I would have thought it would be easy but I can't get it to work. I got as far as saving the CSV Buffer to the Temp Blob and then creating an InStream and then DownloadFromStream but it puts all the lines from the CSV Buffer on the same line in the CSV file. i.e. the CSV file only has one line. Arrrrrrrrh!

  • @Hougaard

    @Hougaard

    2 жыл бұрын

    You need to specify the delimiter.. Can't remember the name of the method for setting that (am out in the wilderness)

Келесі