Article
Julio Francisco · Mar 31, 2019 3m read

Bash script to create csv files for every global contained in a %GOGEN exported file from Cache

Hello

I made for fun a bash script that creates csv files from a %GOGEN exported file.
%GOGEN, the utility for exporting globals for Cache 5.xx

First I thought it would be very simply with bash, but ...
- if I want a header in the csv file
- if you export with GOGEN more globals together not only one
- if I want a csv file for every global/indexes has the global ..

The simply bash script goes up 100 lines of code. If I will start again with this, I would use Python or Go, not bash.

Example:

For a EXPORTED.GLO file

    Transferring files on Mar 30 2019 at 10:24 AM
    ^ALD(20190330

    ^ALD(20190330,"A",99730)
    20190330#20190330#20190330#392224##3020#0##1##1#1#N#500#1# 9:01# 9:01##TLP1####S##3#0#0###N#S##2#D##N###A######0#0#0#0#0#0#0#0#0#0#0#0#0#0###0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#######1###############################
    ^ALD(20190330,"A",99730,"CP",1)
    3#BONIFICACION TERMINAL#1###F#L#A#N###S#
    ^ALD(20190330,"A",99730,"CT")
    TER GZA EL#AV TRE 25#ZAMORA#49008#49#ZAMORA#P1#VALLADOLID#46P#1#49

The script generates 3 csv files. One for regs with 3 index, other for regs with 4 index and another one for 5 index:

  • global ALD with 3 index
    global-EXPORTED_3.csv

         Index1;Index2;Index3;Data1;Data2;Data3;Data4;Data5;Data6;Data7;Data8;Data9;Data10;Data11;Data12;Data13;Data14;Data15;Data16;Data17;Data18;Data19;Data20;Data21;Data22;Data23;Data24;Data25;Data26;Data27;Data28;Data29;Data30;Data31;Data32;Data33;Data34;Data35;Data36;Data37;Data38;Data39;Data40;Data41;Data42;Data43;Data44;Data45;Data46;Data47;Data48;Data49;Data50;Data51;Data52;Data53;Data54;Data55;Data56;Data57;Data58;Data59;Data60;Data61;Data62;Data63;Data64;Data65;Data66;Data67;Data68;Data69;Data70;Data71;Data72;Data73;Data74;Data75;Data76;Data77;Data78;Data79;Data80;Data81;Data82;Data83;Data84;Data85;Data86;Data87;Data88;Data89;Data90;Data91;Data92;Data93;Data94;Data95;Data96;Data97;Data98;Data99;Data100;Data101;Data102;Data103;Data104;Data105;Data106;Data107;Data108;Data109;Data110;Data111;Data112;Data113;Data114;Data115;Data116;
    20190330;"A";99730;20190330;20190330;20190330;392224;;3020;0;;1;;1;1;N;500;1; 9:01; 9:01;;TLP1;;;;S;;3;0;0;;;N;S;;2;D;;N;;;A;;;;;;0;0;0;0;0;0;0;0;0;0;0;0;0;0;;;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;;;;;;;1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    

Data116 is the max number of columns that registers with 3 indexes have.

  • global ALD with 5 index
    global-EXPORTED_5.csv

    Index1;Index2;Index3;Index4;Index5;Data1;Data2;Data3;Data4;Data5;Data6;Data7;Data8;Data9;Data10;Data11;Data12;Data13;
    20190330;"A";99730;"CP";1;3;BONIFICACION TERMINAL;1;;;F;L;A;N;;;S;
    
  • global ALD with 4 index
    global-EXPORTED_4.csv

     Index1;Index2;Index3;Index4;Data1;Data2;Data3;Data4;Data5;Data6;Data7;Data8;Data9;Data10;Data11;Data12;Data13;Data14;Data15;Data16;Data17;
    20190330;"A";99730;"CT";TER GZA EL#AV TRE 25#ZAMORA#49008#49#ZAMORA#P1#VALLADOLID#46P#1#49
    

The source code is here
http://www.sistemasoperativos.org/crear-ficheros-csv-a-partir-de-uno-exp...

Regards

00
2 0 5 406
Log in or sign up to continue

Hi @Julio Francisco ! Nice one!

Do you want to share the code on Github and Open Exchange?

Also, have you tried to craft an export for others tools of exporting globals from InterSystems IRIS?

Thank you

No, thanks, but I'm quitting form github/lab.

I only tried this because at that moment I only need this.

Regards

The script is no longer at the link provided, can you update?