• perl dumper to output tabulated (csv, tab delimitde) format

    From Joe@21:1/5 to All on Tue Nov 10 12:06:16 2020
    My goal was to convert a very large XML file to CSV or tab delimited text.
    I used these to parse XML file:
    my $tpp = XML::TreePP->new();
    my $tree = $tpp->parsefile("$fileName");
    my $text = Dumper( $tree );
    but the output was all in JSON format.

    Is it possible for perl DUMPER to output flat files in csv or tab delimited formats?

    Thanks!
    j

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Keith Thompson@21:1/5 to Joe on Tue Nov 10 13:11:43 2020
    Joe <juliani.moon@gmail.com> writes:
    My goal was to convert a very large XML file to CSV or tab delimited text.
    I used these to parse XML file:
    my $tpp = XML::TreePP->new();
    my $tree = $tpp->parsefile("$fileName");
    my $text = Dumper( $tree );
    but the output was all in JSON format.

    Is it possible for perl DUMPER to output flat files in csv or tab
    delimited formats?

    Data::Dumper's output is not JSON. It's Perl syntax. It doesn't seem
    to have any options for producing something else.

    If you wanted JSON output, you could use the JSON package.

    There are a number of packages that handle CSV, including Text::CSV.

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    Working, but not speaking, for Philips Healthcare
    void Void(void) { Void(); } /* The recursive call of the void */

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From $Bill@21:1/5 to Joe on Tue Nov 10 13:59:25 2020
    On 11/10/2020 12:06, Joe wrote:
    My goal was to convert a very large XML file to CSV or tab delimited text.
    I used these to parse XML file:
    my $tpp = XML::TreePP->new();
    my $tree = $tpp->parsefile("$fileName");
    my $text = Dumper( $tree );
    but the output was all in JSON format.

    Is it possible for perl DUMPER to output flat files in csv or tab delimited formats?

    It should be simple enough to convert from a Perl hash to whatever form
    you want. What does a sample of output look like? I assume $tree is a hash ref
    that contains an array/bunch of hashes that you could easily convert to CSV or tab
    separated text lines.

    do foreach key in hash kinda thingy. Maybe could get complicated if there are sub-hashes or irregular data format.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From George Bouras@21:1/5 to All on Wed Nov 11 21:14:12 2020
    Στις 10/11/2020 10:06 μ.μ., ο/η Joe έγραψε:
    My goal was to convert a very large XML file to CSV or tab delimited text.
    I used these to parse XML file:
    my $tpp = XML::TreePP->new();
    my $tree = $tpp->parsefile("$fileName");
    my $text = Dumper( $tree );
    but the output was all in JSON format.

    Is it possible for perl DUMPER to output flat files in csv or tab delimited formats?

    Thanks!
    j



    send a sample of this xml

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Joe@21:1/5 to Keith Thompson on Mon Nov 30 19:22:46 2020
    On Tuesday, November 10, 2020 at 3:11:49 PM UTC-6, Keith Thompson wrote:
    Joe <julian...@gmail.com> writes:
    My goal was to convert a very large XML file to CSV or tab delimited text. I used these to parse XML file:
    my $tpp = XML::TreePP->new();
    my $tree = $tpp->parsefile("$fileName");
    my $text = Dumper( $tree );
    but the output was all in JSON format.

    Is it possible for perl DUMPER to output flat files in csv or tab
    delimited formats?
    Data::Dumper's output is not JSON. It's Perl syntax. It doesn't seem
    to have any options for producing something else.

    Thank you Keith, you hit the key. I will need to re-approach the problem.
    j

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dr Eberhard W Lisse@21:1/5 to Joe on Fri Dec 4 09:26:05 2020
    https://pagure.io/xmlto/

    el

    On 2020-11-10 22:06 , Joe wrote:
    My goal was to convert a very large XML file to CSV or tab delimited text.
    I used these to parse XML file:
    my $tpp = XML::TreePP->new();
    my $tree = $tpp->parsefile("$fileName");
    my $text = Dumper( $tree );
    but the output was all in JSON format.

    Is it possible for perl DUMPER to output flat files in csv or tab delimited formats?

    Thanks!
    j


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)